Java 类java.awt.event.ComponentEvent 实例源码
项目:incubator-netbeans
文件:EditorCaret.java
/**
* May be called for either component or horizontal scrollbar.
*/
public @Override void componentResized(ComponentEvent e) {
Component c = e.getComponent();
if (c == component) { // called for component
// In case the caretBounds are still null
// (component not connected to hierarchy yet or it has zero size
// so the modelToView() returned null) re-attempt to compute the bounds.
CaretItem caret = getLastCaretItem();
if (caret.getCaretBounds() == null) {
dispatchUpdate(false);
resetBlink();
if (caret.getCaretBounds() != null) { // detach the listener - no longer necessary
c.removeComponentListener(this);
}
}
}
}
项目:QN-ACTR-Release
文件:DistributionsEditor.java
@Override
protected void updateValues(ComponentEvent e) {
// Get the textfield
JTextField sourcefield = (JTextField) e.getSource();
try {
// Get the probability entered in the textfield
Double probability = new Double(Double.parseDouble(sourcefield.getText()));
//Probability has to be smaller or equal than 1 (otherwise don't update value)
if (probability.doubleValue() <= 1.0) {
//If the probability was entered into the probability field of interval B
//then the probability parameter in the distribution has to be set to 1-enteredProbability
if (sourcefield.getName().equals(PROBABILITY_INTERVAL_B)) {
probability = new Double(1 - probability.doubleValue());
}
//set the parameter
current.getParameter(0).setValue(probability);
}
} catch (NumberFormatException ex) {
//If user enters a value that is not a number -> reset value back to the value before
}
refreshValues();
}
项目:defense-solutions-proofs-of-concept
文件:ComponentShowingButton.java
/**
* Sets the component to be shown.
* @param component the component to be shown.
* @param parent the container to which the shown component should be added.
* This parameter can be null if you add the component yourself.
*/
public void setComponent(Component component) {
this.component = component;
if (null != component) {
component.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
if (null != unselectButton && isSelected()) {
unselectButton.setSelected(true);
}
}
});
}
}
项目:openjdk-jdk10
文件:SetShape.java
@Override
public void initGUI() {
if (windowClass.equals(Frame.class)) {
window = new Frame();
((Frame) window).setUndecorated(true);
} else if (windowClass.equals(Dialog.class)) {
window = new Dialog(background);
((Dialog) window).setUndecorated(true);
} else {
window = new Window(background);
}
window.setBackground(FG_COLOR);
window.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
window.setShape(shape);
}
});
window.setSize(200, 200);
window.setLocation(2*dl, 2*dl);
window.setVisible(true);
System.out.println("Checking " + window.getClass().getName() + "...");
}
项目:incubator-netbeans
文件:AutoHideStatusText.java
private AutoHideStatusText( JFrame frame, JPanel statusContainer ) {
this.statusContainer = statusContainer;
Border outerBorder = UIManager.getBorder( "Nb.ScrollPane.border" ); //NOI18N
if( null == outerBorder ) {
outerBorder = BorderFactory.createEtchedBorder();
}
panel.setBorder( BorderFactory.createCompoundBorder( outerBorder,
BorderFactory.createEmptyBorder(3,3,3,3) ) );
lblStatus.setName("AutoHideStatusTextLabel"); //NOI18N
panel.add( lblStatus, BorderLayout.CENTER );
frame.getLayeredPane().add( panel, Integer.valueOf( 101 ) );
StatusDisplayer.getDefault().addChangeListener( this );
frame.addComponentListener( new ComponentAdapter() {
@Override
public void componentResized( ComponentEvent e ) {
run();
}
});
}
项目:openjdk-jdk10
文件:FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
f2dt = demo;
parent = f;
verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
fc = new FontCanvas();
this.setLayout( new BorderLayout() );
this.add( "Center", fc );
this.add( "East", verticalBar );
verticalBar.addAdjustmentListener( this );
this.addComponentListener( new ComponentAdapter() {
public void componentResized( ComponentEvent e ) {
updateFontMetrics = true;
}
});
/// Initialize font and its infos
testFont = new Font(fontName, fontStyle, (int)fontSize);
if ((float)((int)fontSize) != fontSize) {
testFont = testFont.deriveFont(fontSize);
}
updateFontInfo();
}
项目:BachSys
文件:TelaDadosMusica.java
private void adicionarBotaoEditar() {
Tela t = this;
btnEditar = new JButton("Editar");
adicionarComponente(btnEditar, GridBagConstraints.EAST,
GridBagConstraints.NONE, 0, 0, 2, 1);
btnEditar.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
TelaEditarMusica tem = new TelaEditarMusica(musica.getNome(), musica, t);
tem.setVisible(true);
tem.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
musica = tem.getMusica();
editou = true;
adicionarValores();
}
});
}
});
}
项目:incubator-netbeans
文件:UIUtils.java
public static void ensureMinimumSize(Component comp) {
comp = getParentWindow(comp);
if (comp != null) {
final Component top = comp;
top.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
Dimension d = top.getSize();
Dimension min = top.getMinimumSize();
if ((d.width < min.width) || (d.height < min.height)) {
top.setSize(Math.max(d.width, min.width), Math.max(d.height, min.height));
}
}
});
}
}
项目:OpenJSharp
文件:FontPanel.java
public FontPanel( Font2DTest demo, JFrame f ) {
f2dt = demo;
parent = f;
verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
fc = new FontCanvas();
this.setLayout( new BorderLayout() );
this.add( "Center", fc );
this.add( "East", verticalBar );
verticalBar.addAdjustmentListener( this );
this.addComponentListener( new ComponentAdapter() {
public void componentResized( ComponentEvent e ) {
updateBackBuffer = true;
updateFontMetrics = true;
}
});
/// Initialize font and its infos
testFont = new Font(fontName, fontStyle, (int)fontSize);
if ((float)((int)fontSize) != fontSize) {
testFont = testFont.deriveFont(fontSize);
}
updateFontInfo();
}
项目:jmt
文件:DistributionsEditor.java
@Override
protected void updateValues(ComponentEvent e) {
// Finds parameter number
JTextField sourcefield = (JTextField) e.getSource();
int num = Integer.parseInt(sourcefield.getName());
current.getParameter(num).setValue(sourcefield.getText());
current.updateCM();
refreshValues();
}
项目:openjdk-jdk10
文件:DefaultWindowDriver.java
@Override
public void resize(ComponentOperator oper, int width, int height) {
checkSupported(oper);
oper.setSize(width, height);
eDriver.dispatchEvent(oper.getSource(),
new ComponentEvent(oper.getSource(),
ComponentEvent.COMPONENT_RESIZED));
}
项目:intellij-bpmn-editor
文件:BPMNEditorDiagramTab.java
private void installResizeHandler() {
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
fileTab.getGraphComponent().zoomAndCenter();
}
});
}
项目:OpenJSharp
文件:Ruler.java
/**
* Applies the shape to window. It is recommended to apply shape in
* componentResized() method
*/
@Override
public void componentResized(ComponentEvent e) {
// We do apply shape only if PERPIXEL_TRANSPARENT is supported
if (transparencySupported) {
setShape(buildShape());
}
}
项目:TrabalhoFinalEDA2
文件:mxGraphComponent.java
/**
* Applies the zoom policy if the size of the component changes.
*/
protected void installResizeHandler()
{
addComponentListener(new ComponentAdapter()
{
public void componentResized(ComponentEvent e)
{
zoomAndCenter();
}
});
}
项目:Manns-Game-of-Life-Updated-Version
文件:MGoL_Backend.java
@Override
public void componentResized(ComponentEvent e)
{
/*
* This method is responsible for the Array Board always being the dimensions of the User Interface.
* This is necessary when the user changes the size of the Cells within the Array.
* This inadvertently makes the array smaller and thus, the board ensure the array will stay the same size while adding more cells to accomodate.
* This calls the Update Universe Method.
*/
// Setup the game board size with proper boundaries
GameOfLifeDimensions = new Dimension(getWidth()/cellSize-2, getHeight()/cellSize-2);
updateUniverseSize();
}
项目:etomica
文件:DeviceTrioControllerButton.java
public void componentResized(ComponentEvent e){
if(firstResized) { width = jp.getParent().getWidth();firstResized =false;}
if((double)jp.getParent().getWidth()<width){
jp.setLayout(new java.awt.GridLayout(3,1));
jp.updateUI();
} else {
jp.setLayout(new java.awt.GridLayout(1,3));
jp.updateUI();
}
}
项目:Tarski
文件:SimpleGUI.java
/** Called when this window is moved. */
public void componentMoved(ComponentEvent e) {
AnalyzerWidth.set(frame.getWidth());
AnalyzerHeight.set(frame.getHeight());
AnalyzerX.set(frame.getX());
AnalyzerY.set(frame.getY());
}
项目:smile_1.5.0_java7
文件:PlotCanvas.java
@Override
public void componentResized(ComponentEvent e) {
if (graphics != null) {
base.initBaseCoord();
graphics.projection.reset();
baseGrid.setBase(base);
}
repaint();
}
项目:batmapper
文件:MapperPanel.java
@Override
public void componentResized( ComponentEvent e ) {
if (visibleDescs) {
vv.setBounds( 7, BORDERLINE, this.getWidth() - ( DESC_WIDTH + 21 ), this.getHeight() - ( BORDERLINE + 7 ) );
descPanel.setBounds( this.getWidth() - ( 7 + DESC_WIDTH ), BORDERLINE, DESC_WIDTH, SHORT_DESC_HEIGHT + LONG_DESC_HEIGHT + EXITS_HEIGHT + BUTTON_HEIGHT + 4 * 7 );
scrollableNotes.setBounds( this.getWidth() - ( 7 + DESC_WIDTH ), BORDERLINE + descPanel.getHeight() + 7, DESC_WIDTH, this.getHeight() - ( descPanel.getHeight() + 14 + BORDERLINE ) );
} else {
vv.setBounds( 7, BORDERLINE, this.getWidth() - ( 2 * 7 ), this.getHeight() - ( BORDERLINE + 7 ) );
descPanel.setBounds( 0, 0, 0, 0 );
scrollableNotes.setBounds( 0, 0, 0, 0 );
}
}
项目:openjdk-jdk10
文件:XWindowPeer.java
public void setBounds(int x, int y, int width, int height, int op) {
XToolkit.awtLock();
try {
Rectangle oldBounds = getBounds();
super.setBounds(x, y, width, height, op);
Rectangle bounds = getBounds();
XSizeHints hints = getHints();
setSizeHints(hints.get_flags() | XUtilConstants.PPosition | XUtilConstants.PSize,
bounds.x, bounds.y, bounds.width, bounds.height);
XWM.setMotifDecor(this, false, 0, 0);
boolean isResized = !bounds.getSize().equals(oldBounds.getSize());
boolean isMoved = !bounds.getLocation().equals(oldBounds.getLocation());
if (isMoved || isResized) {
repositionSecurityWarning();
}
if (isResized) {
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
}
if (isMoved) {
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
}
} finally {
XToolkit.awtUnlock();
}
}
项目:incubator-netbeans
文件:AbstractMenuFactory.java
public void componentShown(ComponentEvent e) {
JMenu menu = (JMenu) e.getComponent();
String containerCtx = getContainerContext(menu);
System.err.println("ComponentShown: Menu" + containerCtx + " - " + menu);
populateMenu(containerCtx, menu);
getEngine().notifyMenuShown (containerCtx, menu);
}
项目:Tarski
文件:BasicGraphEditor.java
/**
*
*/
public EditorPalette insertPalette(String title)
{
final EditorPalette palette = new EditorPalette();
final JScrollPane scrollPane = new JScrollPane(palette);
scrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
libraryPane.add(title, scrollPane);
// Updates the widths of the palettes if the container size changes
libraryPane.addComponentListener(new ComponentAdapter()
{
/**
*
*/
public void componentResized(ComponentEvent e)
{
int w = scrollPane.getWidth()
- scrollPane.getVerticalScrollBar().getWidth();
palette.setPreferredWidth(w);
}
});
return palette;
}
项目:incubator-netbeans
文件:CustomizerSources.java
public void componentResized(ComponentEvent evt){
double pw = table.getParent().getParent().getSize().getWidth();
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumn column = table.getColumnModel().getColumn(0);
column.setWidth( ((int)pw/2) - 1 );
column.setPreferredWidth( ((int)pw/2) - 1 );
column = table.getColumnModel().getColumn(1);
column.setWidth( ((int)pw/2) - 1 );
column.setPreferredWidth( ((int)pw/2) - 1 );
}
项目:Java-Swing-Helper
文件:SwingWindow.java
/**
* Load a new scene into the frame.</br>
* This will clear out the old scene.
*
* @param scene
*/
public void loadScene(Scene scene) {
if (currentScene != null)
currentScene.unloadScene();
currentScene = scene;
frame.getContentPane().removeAll();
originalComps.clear();
scene.loadScene(frame.getContentPane());
addComponentToList(frame.getContentPane());
// Used to avoid an infinite loop.
originalComps.remove(System.identityHashCode(frame.getContentPane()));
frame.setTitle(title + " - " + scene.getTitle());
frame.getContentPane().repaint();
frame.getContentPane().addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
pack();
}
});
pack();
}
项目:Equella
文件:WizardTab.java
/**
* The size of the tree is now somewhat dynamic. It was getting lost in the
* new big windows :)
*/
@Override
public void componentResized(ComponentEvent event)
{
int treeWidth = (int) (panel.getSize().width * 0.25);
if( treeWidth < MIN_TREE_WIDTH )
{
treeWidth = MIN_TREE_WIDTH;
}
else if( treeWidth > MAX_TREE_WIDTH )
{
treeWidth = MAX_TREE_WIDTH;
}
guiLayout.setColumns(new int[]{treeWidth, TableLayout.FILL});
}
项目:monarch
文件:SequenceDiagram.java
public MemberAxis() {
setPreferredSize(new Dimension(getWidth(), AXIS_SIZE));
SequenceDiagram.this.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
int newWidth = e.getComponent().getWidth();
setPreferredSize(new Dimension(newWidth, AXIS_SIZE));
revalidate();
}
});
}
项目:gate-core
文件:ProgressPanel.java
@Override
public void componentResized(ComponentEvent e) {
int width = Math.min(400, (int)(getSize().width * (2f / 3)));
progressTotal.setMaximumSize(new Dimension(width, progressTotal
.getPreferredSize().height));
progressSingle.setMaximumSize(new Dimension(width, progressSingle
.getPreferredSize().height));
}
项目:rapidminer
文件:GUIInputHandler.java
@Override
public String inputPassword(String messageText) {
final JPasswordField passwordField = new JPasswordField();
JOptionPane jop = new JOptionPane(new Object[] { messageText, passwordField }, JOptionPane.QUESTION_MESSAGE,
JOptionPane.OK_CANCEL_OPTION);
JDialog dialog = jop.createDialog("Auhtentication required");
dialog.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
passwordField.requestFocusInWindow();
passwordField.requestFocus();
}
});
}
});
dialog.setVisible(true);
int result = (Integer) jop.getValue();
if (result == JOptionPane.OK_OPTION) {
return new String(passwordField.getPassword());
} else {
return null;
}
}
项目:TrabalhoFinalEDA2
文件:mxGraphOutline.java
public void componentResized(ComponentEvent e)
{
if (updateScaleAndTranslate())
{
repaintBuffer = true;
updateFinder(false);
repaint();
}
else
{
updateFinder(true);
}
}
项目:org.alloytools.alloy
文件:SimpleGUI.java
/** Called when this window is shown. */
public void componentShown(ComponentEvent e) {}
项目:litiengine
文件:ScreenManager.java
@Override
public void componentResized(final ComponentEvent evt) {
resolution = getRenderComponent().getSize();
ScreenManager.this.resolutionChangedConsumer.forEach(consumer -> consumer.accept(ScreenManager.this.getSize()));
}
项目:VISNode
文件:JNodeContainer.java
@Override
public void componentMoved(ComponentEvent e) {
revalidate();
}
项目:VISNode
文件:JNodeContainer.java
@Override
public void componentShown(ComponentEvent e) {
revalidate();
}
项目:VISNode
文件:JNodeContainer.java
@Override
public void componentHidden(ComponentEvent e) {
revalidate();
}
项目:OpenJSharp
文件:InputContext.java
public void componentShown(ComponentEvent e) {
notifyClientWindowChange((Window)e.getComponent());
}
项目:Manns-Game-of-Life-Updated-Version
文件:MGoL_Backend.java
@Override
public void componentMoved(ComponentEvent e) {}
项目:Manns-Game-of-Life-Updated-Version
文件:MGoL_Backend.java
@Override
public void componentShown(ComponentEvent e) {}
项目:2D-Elliptic-Mesh-Generator
文件:PlotCanvas.java
public void componentMoved(ComponentEvent e) {
}
项目:incubator-netbeans
文件:ComponentWidget.java
public void componentResized (ComponentEvent e) {
revalidate ();
}
项目:Equella
文件:WizardTab.java
@Override
public void componentMoved(ComponentEvent componentevent)
{
// Nothing to do here
}