java.awt.event.ComponentEvent Java Examples
The following examples show how to use
java.awt.event.ComponentEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProgressGlassPane.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** Creates a new instance of ProgressGlassPane */ public ProgressGlassPane() { // blocks all user input addMouseListener(new MouseAdapter() { }); addMouseMotionListener(new MouseMotionAdapter() { }); addKeyListener(new KeyAdapter() { }); setFocusTraversalKeysEnabled(false); addComponentListener(new ComponentAdapter() { public void componentShown(ComponentEvent evt) { requestFocusInWindow(); } }); setBackground(Color.WHITE); setFont(new Font("Default", Font.BOLD, 16)); }
Example #2
Source File: SwingDialog.java From mars-sim with GNU General Public License v3.0 | 6 votes |
@Override public void addNotify() { super.addNotify(); final Component parent = SwingUtilities.getRoot(this); componentListener = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { hidePopUps(); processComponentEvent(new ComponentEvent(JFXPanelEx.this, ComponentEvent.COMPONENT_MOVED)); } @Override public void componentResized(ComponentEvent e) { hidePopUps(); processComponentEvent(new ComponentEvent(JFXPanelEx.this, ComponentEvent.COMPONENT_RESIZED)); processComponentEvent(new ComponentEvent(JFXPanelEx.this, ComponentEvent.COMPONENT_MOVED)); //is important!!! } }; parent.addComponentListener(componentListener); }
Example #3
Source File: MatrixRain.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
public MatrixPanel() { try { InputStream is = MatrixRain.class.getClassLoader().getResourceAsStream( "fonts/katakana.ttf"); Font kf = Font.createFont(Font.TRUETYPE_FONT, is); int fontSize = 14; font = kf.deriveFont(Font.BOLD, fontSize); } catch (Exception exc) { exc.printStackTrace(); } SwingRepaintTimeline.repaintBuilder(this).playLoop(RepeatBehavior.LOOP); this.drops = new ArrayList<>(); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { while (drops.size() < 40) addDrop(); } }); }
Example #4
Source File: AnimationPanel.java From magarena with GNU General Public License v3.0 | 5 votes |
private void setCancelOnResize() { addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (animation != null) { animation.cancel(); } } }); }
Example #5
Source File: Regression_123931_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
public void componentMoved( ComponentEvent cev ) { JFrame jf = (JFrame) cev.getComponent( ); Rectangle r = jf.getBounds( ); setLocation( r.x, r.y + r.height ); setSize( r.width, 50 ); }
Example #6
Source File: DataChartsViewer.java From birt with Eclipse Public License 1.0 | 5 votes |
public void componentShown( ComponentEvent cev ) { JFrame jf = (JFrame) cev.getComponent( ); Rectangle r = jf.getBounds( ); setLocation( r.x, r.y + r.height ); setSize( r.width, 50 ); setVisible( true ); }
Example #7
Source File: ClassViewer.java From bytecode-viewer with GNU General Public License v3.0 | 5 votes |
/** * Whoever wrote this function, THANK YOU! * * @param splitter * @param proportion * @return */ public static JSplitPane setDividerLocation(final JSplitPane splitter, final double proportion) { if (splitter.isShowing()) { if (splitter.getWidth() > 0 && splitter.getHeight() > 0) { splitter.setDividerLocation(proportion); } else { splitter.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent ce) { splitter.removeComponentListener(this); setDividerLocation(splitter, proportion); } }); } } else { splitter.addHierarchyListener(new HierarchyListener() { @Override public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && splitter.isShowing()) { splitter.removeHierarchyListener(this); setDividerLocation(splitter, proportion); } } }); } return splitter; }
Example #8
Source File: Regression_117986_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
public void componentShown( ComponentEvent cev ) { JFrame jf = (JFrame) cev.getComponent( ); Rectangle r = jf.getBounds( ); setLocation( r.x, r.y + r.height ); setSize( r.width, 50 ); setVisible( true ); }
Example #9
Source File: EditRosterService.java From Shuffle-Move with GNU General Public License v3.0 | 5 votes |
@Override protected void onLaunch() { d.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent ev) { ConfigManager preferencesManager = getUser().getPreferencesManager(); Dimension dim = d.getSize(); preferencesManager.setEntry(EntryType.INTEGER, KEY_EDIT_ROSTER_WIDTH, dim.width); preferencesManager.setEntry(EntryType.INTEGER, KEY_EDIT_ROSTER_HEIGHT, dim.height); } }); }
Example #10
Source File: VideoMp4.java From wandora with GNU General Public License v3.0 | 5 votes |
@Override public void componentResized(ComponentEvent e) { Platform.runLater(new Runnable() { @Override public void run() { refreshLayout(); } }); }
Example #11
Source File: Ruler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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()); } }
Example #12
Source File: PreviewArea.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public PreviewArea(Project project, Set<FlutterOutline> outlinesWithWidgets, Disposable parent) { this.outlinesWithWidgets = outlinesWithWidgets; context = new WidgetEditingContext( project, FlutterDartAnalysisServer.getInstance(project), InspectorGroupManagerService.getInstance(project), EditorPositionService.getInstance(project) ); inspectorClient = new InspectorGroupManagerService.Client(parent); context.inspectorGroupManagerService.addListener(inspectorClient, parent); preview = new PreviewViewController(new WidgetViewModelData(context), false, layeredPanel, parent); deviceMirrorPanel = new PreviewViewModelPanel(preview); windowToolbar = ActionManager.getInstance().createActionToolbar("PreviewArea", toolbarGroup, true); toolbarGroup.add(new TitleAction("Device Mirror")); window = new SimpleToolWindowPanel(true, true); window.setToolbar(windowToolbar.getComponent()); deviceMirrorPanel.setLayout(new BorderLayout()); // TODO(jacobr): reafactor to remove the layeredPanel as we aren't getting any benefit from it. window.setContent(layeredPanel); layeredPanel.add(deviceMirrorPanel, Integer.valueOf(0)); // Layers should cover the whole root panel. layeredPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { final Dimension renderSize = getRenderSize(); preview.setScreenshotBounds(new Rectangle(0, 0, renderSize.width, renderSize.height)); } }); }
Example #13
Source File: LuckPopupFactory.java From littleluck with Apache License 2.0 | 5 votes |
@Override public void componentShown(ComponentEvent e) { Object obj = e.getSource(); if(obj instanceof JWindow) { JWindow window = (JWindow) obj; window.repaint(); } }
Example #14
Source File: bug8071705.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void componentShown(ComponentEvent e) { JFrame frame = (JFrame) e.getComponent(); runActualTest(device, latch, frame, result); frame.setVisible(false); frame.dispose(); latch.countDown(); }
Example #15
Source File: Regression_139388_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
public void componentResized( ComponentEvent cev ) { JFrame jf = (JFrame) cev.getComponent( ); Rectangle r = jf.getBounds( ); setLocation( r.x, r.y + r.height ); setSize( r.width, 50 ); }
Example #16
Source File: XWindowPeer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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(); } }
Example #17
Source File: ExpressionView.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public void componentResized(ComponentEvent arg0) { int width = getWidth(); if (renderData != null && Math.abs(renderData.width - width) > 2) { Graphics g = getGraphics(); FontMetrics fm = g == null ? null : g.getFontMetrics(); renderData = new RenderData(renderData.exprData, width, fm); setPreferredSize(renderData.getPreferredSize()); revalidate(); repaint(); } }
Example #18
Source File: Ruler.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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()); } }
Example #19
Source File: MainDesktopPane.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Create background tile when MainDesktopPane is first displayed. Recenter * logoLabel on MainWindow and set backgroundLabel to the size of * MainDesktopPane. * * @param e the component event */ @Override public void componentResized(ComponentEvent e) { // If displayed for the first time, create background image tile. // The size of the background tile cannot be determined during construction // since it requires the MainDesktopPane be displayed first. if (firstDisplay) { ImageIcon baseImageIcon = ImageLoader.getIcon(Msg.getString("img.background")); //$NON-NLS-1$ Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize(); Image backgroundImage = createImage((int) screen_size.getWidth(), (int) screen_size.getHeight()); Graphics backgroundGraphics = backgroundImage.getGraphics(); for (int x = 0; x < backgroundImage.getWidth(this); x += baseImageIcon.getIconWidth()) { for (int y = 0; y < backgroundImage.getHeight(this); y += baseImageIcon.getIconHeight()) { backgroundGraphics.drawImage(baseImageIcon.getImage(), x, y, this); } } backgroundImageIcon.setImage(backgroundImage); backgroundLabel.setSize(getSize()); firstDisplay = false; } // Set the backgroundLabel size to the size of the desktop backgroundLabel.setSize(getSize()); }
Example #20
Source File: DesktopWindowWatcher.java From consulo with Apache License 2.0 | 5 votes |
final void dispatchComponentEvent(final ComponentEvent e) { final int id = e.getID(); if (WindowEvent.WINDOW_CLOSED == id || (ComponentEvent.COMPONENT_HIDDEN == id && e.getSource() instanceof Window)) { dispatchHiddenOrClosed(TargetAWT.from((Window)e.getSource())); } // Clear obsolete reference on root frame if (WindowEvent.WINDOW_CLOSED == id) { final Window window = (Window)e.getSource(); if (JOptionPane.getRootFrame() == window) { JOptionPane.setRootFrame(null); } } }
Example #21
Source File: Regression_137780_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
public void componentShown( ComponentEvent cev ) { JFrame jf = (JFrame) cev.getComponent( ); Rectangle r = jf.getBounds( ); setLocation( r.x, r.y + r.height ); setSize( r.width, 50 ); setVisible( true ); }
Example #22
Source File: PicMap.java From megamek with GNU General Public License v2.0 | 5 votes |
@Override protected void processComponentEvent(ComponentEvent e) { switch (e.getID()) { case ComponentEvent.COMPONENT_RESIZED: onResize(); update(); break; } }
Example #23
Source File: SketchGridPanel.java From wandora with GNU General Public License v3.0 | 4 votes |
private void handleComponentEvent(ComponentEvent e) { this.setPreferredSize(new Dimension(50, 50)); }
Example #24
Source File: StreamOutlierPanel.java From moa with GNU General Public License v3.0 | 4 votes |
@Override public void componentMoved(ComponentEvent e) { }
Example #25
Source File: WLightweightFramePeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public void reshape(int x, int y, int width, int height) { super.reshape(x, y, width, height); postEvent(new ComponentEvent((Component) getTarget(), ComponentEvent.COMPONENT_MOVED)); postEvent(new ComponentEvent((Component) getTarget(), ComponentEvent.COMPONENT_RESIZED)); }
Example #26
Source File: InputContext.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void componentResized(ComponentEvent e) { notifyClientWindowChange((Window)e.getComponent()); }
Example #27
Source File: MarginViewportUI.java From netbeans with Apache License 2.0 | 4 votes |
public void componentShown(ComponentEvent e) { scheduleRepaint(((Component) e.getSource()).getSize()); }
Example #28
Source File: Regression_117699_swing.java From birt with Eclipse Public License 1.0 | 4 votes |
public void componentHidden( ComponentEvent e ) { // TODO Auto-generated method stub }
Example #29
Source File: MultiThumbSliderUI.java From Pixelitor with GNU General Public License v3.0 | 4 votes |
@Override public void componentMoved(ComponentEvent e) { }
Example #30
Source File: FormatChartsViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
public void componentHidden( ComponentEvent cev ) { setVisible( false ); }