java.awt.event.MouseAdapter#java.awt.event.WindowEvent源码实例Demo

下面列出了java.awt.event.MouseAdapter#java.awt.event.WindowEvent 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Pushjet-Android   文件: Application.java
private void setupUI() {
    frame = new JFrame("Gradle");

    JPanel mainPanel = new JPanel(new BorderLayout());
    frame.getContentPane().add(mainPanel);

    mainPanel.add(singlePaneUIInstance.getComponent());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    singlePaneUIInstance.aboutToShow();

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            close();
        }
    });

    frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    frame.setLocationByPlatform(true);
}
 
源代码2 项目: CQL   文件: JFontChooser.java
/**
 * Show font selection dialog.
 * 
 * @param parent Dialog's Parent component.
 * @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
 *
 * @see #OK_OPTION
 * @see #CANCEL_OPTION
 * @see #ERROR_OPTION
 **/
public int showDialog(Component parent) {
	dialogResultValue = ERROR_OPTION;
	JDialog dialog = createDialog(parent);
	dialog.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			dialogResultValue = CANCEL_OPTION;
		}
	});

	dialog.setVisible(true);
	dialog.dispose();
	dialog = null;

	return dialogResultValue;
}
 
源代码3 项目: openjdk-jdk9   文件: JFrame.java
/**
 * Processes window events occurring on this component.
 * Hides the window or disposes of it, as specified by the setting
 * of the <code>defaultCloseOperation</code> property.
 *
 * @param  e  the window event
 * @see    #setDefaultCloseOperation
 * @see    java.awt.Window#processWindowEvent
 */
protected void processWindowEvent(final WindowEvent e) {
    super.processWindowEvent(e);

    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        switch (defaultCloseOperation) {
            case HIDE_ON_CLOSE:
                setVisible(false);
                break;
            case DISPOSE_ON_CLOSE:
                dispose();
                break;
            case EXIT_ON_CLOSE:
                // This needs to match the checkExit call in
                // setDefaultCloseOperation
                System.exit(0);
                break;
            case DO_NOTHING_ON_CLOSE:
            default:
        }
    }
}
 
源代码4 项目: openjdk-jdk9   文件: Util.java
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
    EventListener listener = null;

    switch (eventID) {
    case WindowEvent.WINDOW_GAINED_FOCUS:
        listener = wgfListener;
        break;
    case FocusEvent.FOCUS_GAINED:
        listener = fgListener;
        break;
    case ActionEvent.ACTION_PERFORMED:
        listener = apListener;
        break;
    }

    listener.listen(comp, printEvent);
    action.run();
    return Util.waitForCondition(listener.getNotifier(), time);
}
 
源代码5 项目: MeteoInfo   文件: MapLayout.java
/**
 * Show measurment form
 */
public void showMeasurementForm() {
    if (_frmMeasure == null) {
        _frmMeasure = new FrmMeasurement((JFrame) SwingUtilities.getWindowAncestor(this), false);
        _frmMeasure.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(false);
                //repaint();
                repaintOld();
            }
        });
        _frmMeasure.setLocationRelativeTo(this);
        _frmMeasure.setVisible(true);
    } else if (!_frmMeasure.isVisible()) {
        _frmMeasure.setVisible(true);
    }
}
 
源代码6 项目: amidst   文件: ProfileSelectWindow.java
@CalledOnlyBy(AmidstThread.EDT)
private JFrame createFrame() {
	JFrame frame = new JFrame("Profile Selector");
	frame.setIconImages(metadata.getIcons());
	frame.getContentPane().setLayout(new MigLayout());
	frame.add(createTitleLabel(), "h 20!,w :400:, growx, pushx, wrap");
	frame.add(createScrollPanel(), getScrollPaneLayoutString());
	frame.pack();
	frame.addKeyListener(profileSelectPanel.createKeyListener());
	frame.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			application.exitGracefully();
		}
	});
	frame.setLocation(200, 200);
	frame.setVisible(true);
	return frame;
}
 
源代码7 项目: Digital   文件: NumberingWizard.java
/**
 * Creates a new instance
 *
 * @param parent           the parent frame
 * @param circuitComponent the component used to select the inputs and outputs
 */
public NumberingWizard(JFrame parent, CircuitComponent circuitComponent) {
    super(parent, Lang.get("msg_numberingWizard"), false);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    this.circuitComponent = circuitComponent;
    label = new JLabel();
    label.setFont(Screen.getInstance().getFont(1.5f));
    int b = Screen.getInstance().getFontSize();
    label.setBorder(BorderFactory.createEmptyBorder(b, b, b, b));
    setPinNumber(999);
    getContentPane().add(label);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent windowEvent) {
            circuitComponent.deactivateWizard();
        }
    });
    pack();

    pinNumber = 1;
    setPinNumber(pinNumber);
    setLocation(parent.getLocation());
}
 
源代码8 项目: java-swing-tips   文件: MainPanel.java
@Override public void actionPerformed(ActionEvent e) {
  Component root;
  Container parent = SwingUtilities.getUnwrappedParent((Component) e.getSource());
  if (parent instanceof JPopupMenu) {
    JPopupMenu popup = (JPopupMenu) parent;
    root = SwingUtilities.getRoot(popup.getInvoker());
  } else if (parent instanceof JToolBar) {
    JToolBar toolbar = (JToolBar) parent;
    if (((BasicToolBarUI) toolbar.getUI()).isFloating()) {
      root = SwingUtilities.getWindowAncestor(toolbar).getOwner();
    } else {
      root = SwingUtilities.getRoot(toolbar);
    }
  } else {
    root = SwingUtilities.getRoot(parent);
  }
  if (root instanceof Window) {
    Window window = (Window) root;
    window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
  }
}
 
源代码9 项目: consulo   文件: DesktopIdeFrameImpl.java
private void setupCloseAction() {
  myJFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  myJFrame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(@Nonnull final WindowEvent e) {
      if (isTemporaryDisposed()) return;

      final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
      if (openProjects.length > 1 || openProjects.length == 1 && TopApplicationMenuUtil.isMacSystemMenu) {
        if (myProject != null && myProject.isOpen()) {
          ProjectUtil.closeAndDispose(myProject);
        }
        ApplicationManager.getApplication().getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).projectFrameClosed();
        WelcomeFrame.showIfNoProjectOpened();
      }
      else {
        Application.get().exit();
      }
    }
  });
}
 
源代码10 项目: jdk8u60   文件: Font2DTest.java
private void loadComparisonPNG( String fileName ) {
    try {
        BufferedImage image =
            javax.imageio.ImageIO.read(new File(fileName));
        JFrame f = new JFrame( "Comparison PNG" );
        ImagePanel ip = new ImagePanel( image );
        f.setResizable( false );
        f.getContentPane().add( ip );
        f.addWindowListener( new WindowAdapter() {
            public void windowClosing( WindowEvent e ) {
                ( (JFrame) e.getSource() ).dispose();
            }
        });
        f.pack();
        f.show();
    }
    catch ( Exception ex ) {
        fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true );
        ex.printStackTrace();
    }
}
 
源代码11 项目: openjdk-jdk9   文件: EditPad.java
@Override
public void run() {
    JFrame jframe = new JFrame(windowLabel == null
            ? getResourceString("editpad.name")
            : windowLabel);
    Runnable closer = () -> {
        jframe.setVisible(false);
        jframe.dispose();
        closeMark.run();
    };
    jframe.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            closer.run();
        }
    });
    jframe.setLocationRelativeTo(null);
    jframe.setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea(initialText);
    textArea.setFont(new Font("monospaced", Font.PLAIN, 13));
    jframe.add(new JScrollPane(textArea), BorderLayout.CENTER);
    jframe.add(buttons(closer, textArea), BorderLayout.SOUTH);

    jframe.setSize(800, 600);
    jframe.setVisible(true);
}
 
源代码12 项目: IBC   文件: StopTask.java
private void stop() {
    JFrame jf = MainWindowManager.mainWindowManager().getMainWindow();
    
    WindowEvent wev = new WindowEvent(jf, WindowEvent.WINDOW_CLOSING);
    Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev);

    writeAck("Shutting down");
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: TargetFileListFrame.java
private void initGUI(Point location) {
    this.setLocation(location);
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            TargetFileListFrame.this.dispose();
        }
    });
    this.add(new Panel().add(list));
    this.pack();
    this.setVisible(true);
}
 
源代码14 项目: netbeans   文件: EditableDisplayerTest.java
public void windowOpened(WindowEvent e) {
    shown = true;
    synchronized(this) {
        //System.err.println("window opened");
        notifyAll();
        ((JFrame) e.getSource()).removeWindowListener(this);
    }
}
 
源代码15 项目: rapidminer-studio   文件: SettingsDialog.java
/**
 * Sets up the related {@link SettingsTabs} and buttons for the Studio settings. This uses {@link #getDefaultStudioHandler()}
 * and {@link SettingsItems#INSTANCE} for initialization.
 *
 * Selects the specified selected tab.
 *
 * @param initialSelectedTab
 *            A key of a preferences group to identify the initial selected tab.
 */
public SettingsDialog(String initialSelectedTab) {
	this(getDefaultStudioHandler(), SettingsItems.INSTANCE, initialSelectedTab);
	// add listener to remove parameter handler when dialog is closed
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosed(WindowEvent e) {
			parameterHandler.getParameters().getParameterTypes().stream()
					.flatMap(pt -> pt.getConditions().stream()).forEach(pc -> pc.setParameterHandler(null));
		}
	});
}
 
public void init() {
    robot = Util.createRobot();
    kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {
            System.out.println("--> " + event);
        }
    }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
}
 
源代码17 项目: IBC   文件: AbstractLoginHandler.java
@Override
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
            return true;
        default:
            return false;
    }
}
 
源代码18 项目: openjdk-8   文件: TargetFileListFrame.java
private void initGUI(Point location) {
    this.setLocation(location);
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            TargetFileListFrame.this.dispose();
        }
    });
    this.add(new Panel().add(list));
    this.pack();
    this.setVisible(true);
}
 
源代码19 项目: bigtable-sql   文件: FileViewerFactory.java
/**
		 * Viewer has been closed so allow it to be garbage collected.
		 */
//		public void internalFrameClosed(InternalFrameEvent evt)
		public void windowClosed(WindowEvent evt)
		{
//			removeViewer((HtmlViewerSheet)evt.getInternalFrame());
			removeViewer((HtmlViewerSheet)evt.getWindow());
//			super.internalFrameClosed(evt);
		}
 
源代码20 项目: IBC   文件: NonBrokerageAccountDialogHandler.java
@Override
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
            return true;
        default:
            return false;
    }
}
 
源代码21 项目: TencentKona-8   文件: MultimonFullscreenTest.java
public void windowClosing(WindowEvent we) {
    done = true;
    Window w = (Window)we.getSource();
    if (setNullOnDispose) {
        w.getGraphicsConfiguration().getDevice().setFullScreenWindow(null);
    }
    w.dispose();
}
 
源代码22 项目: netbeans   文件: CustomizerProviderImpl.java
public void windowClosing( WindowEvent e ) {
    //Dispose the dialog otherwsie the {@link WindowAdapter#windowClosed}
    //may not be called
    Dialog dialog = (Dialog)project2Dialog.get( project );
    if ( dialog != null ) {
        dialog.setVisible(false);
        dialog.dispose();
    }
}
 
源代码23 项目: jdk8u-jdk   文件: ContainerFocusAutoTransferTest.java
public void init() {
    robot = Util.createRobot();
    kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {
            System.out.println("--> " + event);
        }
    }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
}
 
源代码24 项目: dragonwell8_jdk   文件: SunToolkit.java
public static void postEvent(AppContext appContext, AWTEvent event) {
    if (event == null) {
        throw new NullPointerException();
    }

    AWTAccessor.SequencedEventAccessor sea = AWTAccessor.getSequencedEventAccessor();
    if (sea != null && sea.isSequencedEvent(event)) {
        AWTEvent nested = sea.getNested(event);
        if (nested.getID() == WindowEvent.WINDOW_LOST_FOCUS &&
            nested instanceof TimedWindowEvent)
        {
            TimedWindowEvent twe = (TimedWindowEvent)nested;
            ((SunToolkit)Toolkit.getDefaultToolkit()).
                setWindowDeactivationTime((Window)twe.getSource(), twe.getWhen());
        }
    }

    // All events posted via this method are system-generated.
    // Placing the following call here reduces considerably the
    // number of places throughout the toolkit that would
    // otherwise have to be modified to precisely identify
    // system-generated events.
    setSystemGenerated(event);
    AppContext eventContext = targetToAppContext(event.getSource());
    if (eventContext != null && !eventContext.equals(appContext)) {
        throw new RuntimeException("Event posted on wrong app context : " + event);
    }
    PostEventQueue postEventQueue =
        (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
    if (postEventQueue != null) {
        postEventQueue.postEvent(event);
    }
}
 
源代码25 项目: mylizzie   文件: ByoYomiAutoPlayDialog.java
private void thisWindowClosing(WindowEvent e) {
    countdownSystemStop();
    stopCountdown();
    Lizzie.board.unregisterBoardStateChangeObserver(boardStateChangeObserver);

    OptionSetting.ByoYomiSetting byoYomiSetting = Lizzie.optionSetting.getByoYomiSetting();
    byoYomiSetting.setByoYomiTime((Integer) spinnerCountdownTime.getValue());
    byoYomiSetting.setStopThinkingWhenCountingDown(checkBoxStopThinkingWhenCountDown.isSelected());
}
 
源代码26 项目: TrakEM2   文件: FilePathRepair.java
private final Runnable makeGUI() {
	return new Runnable() { public void run() {
		JScrollPane jsp = new JScrollPane(table);
		jsp.setPreferredSize(new Dimension(500, 500));
		table.addMouseListener(listener);
		JLabel label = new JLabel("Double-click any to repair file path:");
		JLabel label2 = new JLabel("(Any listed with identical parent folder will be fixed as well.)");
		JPanel plabel = new JPanel();
		BoxLayout pbl = new BoxLayout(plabel, BoxLayout.Y_AXIS);
		plabel.setLayout(pbl);
		//plabel.setBorder(new LineBorder(Color.black, 1, true));
		plabel.setMinimumSize(new Dimension(400, 40));
		plabel.add(label);
		plabel.add(label2);
		JPanel all = new JPanel();
		BoxLayout bl = new BoxLayout(all, BoxLayout.Y_AXIS);
		all.setLayout(bl);
		all.add(plabel);
		all.add(jsp);
		frame.getContentPane().add(all);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent we) {
				synchronized (projects) {
					if (data.vpath.size() > 0 ) {
						Utils.logAll("WARNING: Some images remain associated to inexistent file paths.");
					}
					projects.remove(project);
				}
			}
		});
		frame.pack();
		ij.gui.GUI.center(frame);
		frame.setVisible(true);
	}};
}
 
源代码27 项目: netbeans   文件: ProjectCustomizerProvider.java
@Override
public void windowClosing (WindowEvent e) {
    //Dispose the dialog otherwsie the {@link WindowAdapter#windowClosed}
    //may not be called
    Dialog dialog = project2Dialog.get( project );
    if ( dialog != null ) {
        dialog.setVisible(false);
        dialog.dispose();
    }
}
 
源代码28 项目: aifh   文件: ElementaryCA.java
/**
 * {@inheritDoc}
 */
@Override
public void windowActivated(WindowEvent arg0) {
    // TODO Auto-generated method stub

}
 
源代码29 项目: MikuMikuStudio   文件: MaterialBrowser.java
public void windowClosed(WindowEvent e) {
}
 
源代码30 项目: JDKSourceCode1.8   文件: PopupFactory.java
/**
 * Recycles the passed in <code>HeavyWeightPopup</code>.
 */
private static void recycleHeavyWeightPopup(HeavyWeightPopup popup) {
    synchronized (HeavyWeightPopup.class) {
        List<HeavyWeightPopup> cache;
        Window window = SwingUtilities.getWindowAncestor(
                             popup.getComponent());
        Map<Window, List<HeavyWeightPopup>> heavyPopupCache = getHeavyWeightPopupCache();

        if (window instanceof Popup.DefaultFrame ||
                              !window.isVisible()) {
            // If the Window isn't visible, we don't cache it as we
            // likely won't ever get a windowClosed event to clean up.
            // We also don't cache DefaultFrames as this indicates
            // there wasn't a valid Window parent, and thus we don't
            // know when to clean up.
            popup._dispose();
            return;
        } else if (heavyPopupCache.containsKey(window)) {
            cache = heavyPopupCache.get(window);
        } else {
            cache = new ArrayList<HeavyWeightPopup>();
            heavyPopupCache.put(window, cache);
            // Clean up if the Window is closed
            final Window w = window;

            w.addWindowListener(new WindowAdapter() {
                public void windowClosed(WindowEvent e) {
                    List<HeavyWeightPopup> popups;

                    synchronized(HeavyWeightPopup.class) {
                        Map<Window, List<HeavyWeightPopup>> heavyPopupCache2 =
                                      getHeavyWeightPopupCache();

                        popups = heavyPopupCache2.remove(w);
                    }
                    if (popups != null) {
                        for (int counter = popups.size() - 1;
                                           counter >= 0; counter--) {
                            popups.get(counter)._dispose();
                        }
                    }
                }
            });
        }

        if(cache.size() < MAX_CACHE_SIZE) {
            cache.add(popup);
        } else {
            popup._dispose();
        }
    }
}