/** * 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); } } } }
@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(); }
/** * 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); } } }); } }
@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() + "..."); }
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(); } }); }
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(); }
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(); } }); } }); }
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)); } } }); } }
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(); }
@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(); }
@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)); }
private void installResizeHandler() { addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { fileTab.getGraphComponent().zoomAndCenter(); } }); }
/** * 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()); } }
/** * Applies the zoom policy if the size of the component changes. */ protected void installResizeHandler() { addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { zoomAndCenter(); } }); }
@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(); }
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(); } }
/** 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()); }
@Override public void componentResized(ComponentEvent e) { if (graphics != null) { base.initBaseCoord(); graphics.projection.reset(); baseGrid.setBase(base); } repaint(); }
@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 ); } }
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(); } }
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); }
/** * */ 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; }
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 ); }
/** * 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(); }
/** * 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}); }
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(); } }); }
@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)); }
@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; } }
public void componentResized(ComponentEvent e) { if (updateScaleAndTranslate()) { repaintBuffer = true; updateFinder(false); repaint(); } else { updateFinder(true); } }
/** Called when this window is shown. */ public void componentShown(ComponentEvent e) {}
@Override public void componentResized(final ComponentEvent evt) { resolution = getRenderComponent().getSize(); ScreenManager.this.resolutionChangedConsumer.forEach(consumer -> consumer.accept(ScreenManager.this.getSize())); }
@Override public void componentMoved(ComponentEvent e) { revalidate(); }
@Override public void componentShown(ComponentEvent e) { revalidate(); }
@Override public void componentHidden(ComponentEvent e) { revalidate(); }
public void componentShown(ComponentEvent e) { notifyClientWindowChange((Window)e.getComponent()); }
@Override public void componentMoved(ComponentEvent e) {}
@Override public void componentShown(ComponentEvent e) {}
public void componentMoved(ComponentEvent e) { }
public void componentResized (ComponentEvent e) { revalidate (); }
@Override public void componentMoved(ComponentEvent componentevent) { // Nothing to do here }