Java 类java.awt.event.WindowListener 实例源码

项目:incubator-netbeans    文件:RevisionPicker.java   
public boolean open () {
    dd = new DialogDescriptor(panel, NbBundle.getMessage(RevisionPicker.class, "LBL_RevisionPickerDialog.title"), //NOI18N
            true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx("org.netbeans.modules.git.ui.repository.RevisionPickerDialog"), null); //NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    updateDialogState();
    browserPanel.addPropertyChangeListener(this);
    Preferences prefs = GitModuleConfig.getDefault().getPreferences();
    WindowListener windowListener = new DialogBoundsPreserver(prefs, this.getClass().getName());
    dialog.addWindowListener(windowListener);
    windowListener.windowOpened(new WindowEvent(dialog, WindowEvent.WINDOW_OPENED));
    dialog.pack();
    updateSliders(prefs);
    dialog.setVisible(true);
    persistSliders(prefs);
    browserPanel.removePropertyChangeListener(this);
    return dd.getValue() == okButton;
}
项目:OpenJSharp    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:jdk8u-jdk    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:openjdk-jdk10    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:openjdk9    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:hiervis    文件:SwingUIUtils.java   
/**
 * Creates and registers a {@link WindowListener} to {@code parent} window, which causes
 * the {@code child} window to close when the {@code parent} window is closed.
 * 
 * @param parent
 *            the window whose closing will cause child to close as well.
 * @param child
 *            the window that will be closed when parent is closed.
 * @return the created listener
 */
public static WindowListener addCloseCallback( Window parent, Window child )
{
    return addCloseCallback(
        parent, () -> {
            // Dispatch closing event instead of calling dispose() directly,
            // so that event listeners are notified.
            child.dispatchEvent(
                new WindowEvent(
                    child,
                    WindowEvent.WINDOW_CLOSING
                )
            );
        }
    );
}
项目:Java8CN    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:jdk8u_jdk    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:lookaside_java-1.8.0-openjdk    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:GArduino    文件:Run.java   
public Run(){//metodo costruttore del JFrame

       WindowListener li = new WindowAdapter(){ //creo listener per controllare la pressione del pulsante di chiusura
         @Override
         public void windowClosing(WindowEvent e){//se il pulsante "x" è premuto, esco

             System.exit(0);
         }  
      };

GArduino g =  new GArduino();//creo il JPanel GArduino

      this.addWindowListener(li);//aggiungo il listener al JFrame
      super.getContentPane().add(g);//aggiungo il JPanel al JFrame
      this.setTitle("GArduino Controller");//imposto il titolo della finestra
      super.setVisible(true);//imposto la visbilità
      super.setResizable(false);//imposto la non possibilità di modificare le dimensioni della finestra
      super.setSize(900,600);//imposto le dimensioni della finestra
      super.setLocationRelativeTo(null);

   }
项目:beautyeye    文件:SwingSet2.java   
/**
 * Create a frame for SwingSet2 to reside in if brought up
 * as an application.
 *
 * @param gc the gc
 * @return the j frame
 */
public static JFrame createFrame(GraphicsConfiguration gc) {
    JFrame frame = new JFrame(gc);
    if (numSSs == 0) {
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } else {
        WindowListener l = new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                numSSs--;
                swingSets.remove(this);
            }
        };
        frame.addWindowListener(l);
    }

    //由Jack Jiang于2012-09-22加上,防止因JToolBar的大小而影响JFrame的prefereSize使得没法再缩小
    frame.setMinimumSize(new Dimension(100,100));
    return frame;
}
项目:fil_project_mgmt_app_v2    文件:JCalendarDemo.java   
/**
 * Creates a JFrame with a JCalendarDemo inside and can be used for testing.
 * 
 * @param s
 *            The command line arguments
 */
public static void main(String[] s) {
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };

    JFrame frame = new JFrame("JCalendar Demo");
    frame.addWindowListener(l);

    JCalendarDemo demo = new JCalendarDemo();
    demo.init();
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setBounds(200, 200,
            (int) frame.getPreferredSize().getWidth() + 40, (int) frame
                    .getPreferredSize().getHeight() + 250);
    frame.setVisible(true);
}
项目:java-ui-factory    文件:WindowFactory.java   
@Override
protected void wireComponent(final ComponentContext context) {

    super.wireComponent(context);

    final Window window = (Window) context.getComponent();

    final MethodListenerProxy<WindowListener> windowListenerProxy = new MethodListenerProxy<WindowListener>(
            WindowListener.class, context.getActionListeners());

    final MethodListenerProxy<WindowFocusListener> windowFocusListenerProxy = new MethodListenerProxy<WindowFocusListener>(
            WindowFocusListener.class, context.getActionListeners());

    if (windowListenerProxy.hasListeningMethod()) {
        window.addWindowListener(windowListenerProxy.getProxy());
        LOGGER.debug("{}|Window.addWindowListener", context.getId());
    }

    if (windowFocusListenerProxy.hasListeningMethod()) {
        window.addWindowFocusListener(windowFocusListenerProxy.getProxy());
        LOGGER.debug("{}|Window.addWindowFocusListener", context.getId());
    }
}
项目:infobip-open-jdk-8    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:jdk8u-dev-jdk    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:jdk7-jdk    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:openjdk-source-code-learn    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:OLD-OpenJDK8    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:BamQC    文件:HorizontalBarGraph.java   
public static void main(String[] argv) {
    JFrame f = new JFrame();
    f.setSize(600, 400);
    double[] values = new double[4];
    String[] names = new String[3];
    names[0] = "Item 1";
    values[0] = 0.00100000000;
    names[1] = "Very long Item 2";
    values[1] = 0.00200000;
    names[2] = "Item 3";
    values[2] = 0.00200000000;



    f.getContentPane().add(new HorizontalBarGraph(names, values, "Counts", "Stacked Horizontal Bar Graph Test"));

    WindowListener wndCloser = new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent e) {
        System.exit(0);
       }
    };
   f.addWindowListener(wndCloser);
   f.setVisible(true);
}
项目:openjdk-jdk7u-jdk    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:JCalendar    文件:JCalendarDemo.java   
/**
 * Creates a JFrame with a JCalendarDemo inside and can be used for testing.
 * 
 * @param s
 *            The command line arguments
 */
public static void main(String[] s) {
    WindowListener l = new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };

    JFrame frame = new JFrame("JCalendar Demo");
    frame.addWindowListener(l);

    JCalendarDemo demo = new JCalendarDemo();
    demo.init();
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setBounds(200, 200,
            (int) frame.getPreferredSize().getWidth() + 40, (int) frame
                    .getPreferredSize().getHeight() + 250);
    frame.setVisible(true);
}
项目:spring-rich-client    文件:JideApplicationWindow.java   
/**
 * Overridden close method to avoid memory leaks by Mikael Valot
 */
public boolean close(){
    if(super.close()){
        dockableHolder.dispose();
        dockableHolder.removeWindowFocusListener(this);
        WindowListener[] listeners = dockableHolder.getWindowListeners();
        for(int i=0;i<listeners.length;i++){
            dockableHolder.removeWindowListener(listeners[i]);
        }
        Lm.setParent(null);
        dockableHolder.removeAll();
        dockableHolder.getRootPane().removeAll();
        dockableHolder = null;
        return true;
    }
    else{
        return false;
    }
}
项目:cloudstack    文件:Client.java   
protected static Frame createVncClientMainWindow(BufferedImageCanvas canvas, String title, WindowListener windowListener) {
    // Create AWT windows
    Frame frame = new Frame(title + " - RDP");

    // Use scrolling pane to support screens, which are larger than ours
    scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
    scroller.add(canvas);
    scroller.setSize(canvas.getWidth(), canvas.getHeight());

    frame.add(scroller);
    frame.pack();
    frame.setVisible(true);

    frame.addWindowListener(windowListener);

    return frame;
}
项目:openjdk-icedtea7    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:cagrid-general    文件:GridProxyInit.java   
public static void main(String args[]) {

CertUtil.init();

       GridProxyInit gpiFrame = new GridProxyInit(null, true);
gpiFrame.setRunAsApplication(true);
gpiFrame.saveProxy(true);

       WindowListener l = new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }
    };

gpiFrame.addWindowListener(l);
gpiFrame.pack();
UITools.center(null, gpiFrame);
       gpiFrame.setVisible(true);
   }
项目:spring-richclient    文件:JideApplicationWindow.java   
/**
 * Overridden close method to avoid memory leaks by Mikael Valot
 */
public boolean close(){
    if(super.close()){
        dockableHolder.dispose();
        dockableHolder.removeWindowFocusListener(this);
        WindowListener[] listeners = dockableHolder.getWindowListeners();
        for(int i=0;i<listeners.length;i++){
            dockableHolder.removeWindowListener(listeners[i]);
        }
        Lm.setParent(null);
        dockableHolder.removeAll();
        dockableHolder.getRootPane().removeAll();
        dockableHolder = null;
        return true;
    }
    else{
        return false;
    }
}
项目:eXamine    文件:Modules.java   
private static void initVisualization() {
    visualization = new Visualization();

    // Override default Exit Application listener -> enforce hide.
    for(WindowListener wl: visualization.getWindowListeners()) {
        visualization.removeWindowListener(wl);
    }
    visualization.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }

    });

    visualization.setVisible(true);
}
项目:org.datagr4m    文件:PopupHelper.java   
public static JFrame popupFrame(String title, String message, int width, int height, WindowListener listener) {
    Color bg = Color.WHITE;

    JFrame frame = new JFrame(title);
    JLabel label = new JLabel(message);
    label.setBackground(bg);
    label.setBorder(BorderFactory.createBevelBorder(1));
    label.setVerticalTextPosition(SwingConstants.TOP);
    label.setHorizontalTextPosition(SwingConstants.RIGHT);
    label.setOpaque(true);
    frame.add(label);
    frame.setBackground(bg);
    frame.setSize(width, height);
    frame.addWindowListener(listener);
    frame.show();
    return frame;
}
项目:NK-VirtualGlobe    文件:Main.java   
/** Creates a new instance of Main */
public Main(String[] args) {
    camera = ViewerManager.getInstance().createPerspectiveCamera(new GlobeNavigator(null));

    WalkPerspectiveNavigationAdapter navigationAdapter = new WalkPerspectiveNavigationAdapter(camera);
    camera.getCanvas().addKeyListener(navigationAdapter);
    camera.getCanvas().addMouseListener(navigationAdapter);
    camera.getCanvas().addMouseMotionListener(navigationAdapter);
    camera.getCanvas().addMouseWheelListener(navigationAdapter);
    if (camera instanceof WindowListener)
        addWindowListener((WindowListener)camera);

    Component graphic_view = camera.getGraphicsView();
    graphic_view.setPreferredSize(new Dimension(800, 600));
    this.getContentPane().add(graphic_view, BorderLayout.CENTER);

    URL dataset = ApplicationUtils.extractDataset(args);
    universe.setDataSet(dataset);

    double [] vp = ApplicationUtils.extractViewpoint(args);
    if (vp != null) {
        camera.getNavigator().gotoViewpoint(vp[0], vp[1], vp[2], vp[3], vp[4]);
    }
}
项目:NK-VirtualGlobe    文件:Main.java   
/** Creates a new instance of Main */
public Main(String[] args) {
    camera = ViewerManager.getInstance().createPerspectiveCamera(new GlobeNavigator(null));

    WalkPerspectiveNavigationAdapter navigationAdapter = new WalkPerspectiveNavigationAdapter(camera);
    camera.getCanvas().addKeyListener(navigationAdapter);
    camera.getCanvas().addMouseListener(navigationAdapter);
    camera.getCanvas().addMouseMotionListener(navigationAdapter);
    camera.getCanvas().addMouseWheelListener(navigationAdapter);
    if (camera instanceof WindowListener)
        addWindowListener((WindowListener)camera);

    Component graphic_view = camera.getGraphicsView();
    graphic_view.setPreferredSize(new Dimension(300, 300));
    this.getContentPane().add(graphic_view, BorderLayout.CENTER);

    URL dataset = extractDataset(args);
    universe.setDataSet(dataset);
}
项目:reactive-stream-swing    文件:WindowClosingEventSubject.java   
@Override
protected WindowListener onSubscribe(final Observer<? super WindowEvent> observer) {
    LOG.trace("onSubscribe(): {}", observer);

    checkNotNull(observer, "observer");

    final WindowListener listener = new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            LOG.trace("windowClosing(): {}", e);
            onNext(e);
        }
    };

    window.addWindowListener(listener);

    return listener;
}
项目:msInspect    文件:SwingEngine.java   
/**
 * Displays the GUI during a RAD session. If the root component is neither a JFrame nor a JDialog, the a JFrame is
 * instantiated and the root is added into the new frames contentpane.
 */
public void test() {
  WindowListener wl = new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
      super.windowClosing(e);
      System.exit(0);
    }
  };
  if (root != null) {
    if (JFrame.class.isAssignableFrom(root.getClass())
            || JDialog.class.isAssignableFrom(root.getClass())) {
      ((Window) root).addWindowListener(wl);
      root.setVisible(true);
    } else {
      JFrame jf = new JFrame("SwiXml Test");
      jf.getContentPane().add(root);
      jf.pack();
      jf.addWindowListener(wl);
      jf.setVisible(true);
    }
  }
}
项目:osp    文件:Launcher.java   
private void exitCurrentApps() {
  final Frame[] prevFrames = Frame.getFrames();
  for(int i = 0, n = prevFrames.length; i<n; i++) {
    if(existingFrames.contains(prevFrames[i])) {
      continue; // don't mess with pre-existing frames such as the applet plugin
    }
    if(!(prevFrames[i] instanceof LauncherFrame)) {
      WindowListener[] listeners = prevFrames[i].getWindowListeners();
      for(int j = 0; j<listeners.length; j++) {
        listeners[j].windowClosing(null);
      }
      if(prevFrames[i].isVisible()) {
        prevFrames[i].dispose();
      }
    }
  }
}
项目:imagetozxspec    文件:ImageToZxSpec.java   
/**
 * Creates a window listener that shuts down the app gracefully
 * 
 * @return the window listener
 */
private WindowListener createWindowListener() {
    // Override the window close listener to clear up resources 
    return new WindowAdapter() {
            public void windowClosing(WindowEvent w) {
                shutdown();
            }
    };
}
项目:openjdk-jdk10    文件:WindowOperator.java   
/**
 * Maps {@code Window.addWindowListener(WindowListener)} through queue
 */
public void addWindowListener(final WindowListener windowListener) {
    runMapping(new MapVoidAction("addWindowListener") {
        @Override
        public void map() {
            ((Window) getSource()).addWindowListener(windowListener);
        }
    });
}
项目:openjdk-jdk10    文件:WindowOperator.java   
/**
 * Maps {@code Window.removeWindowListener(WindowListener)} through queue
 */
public void removeWindowListener(final WindowListener windowListener) {
    runMapping(new MapVoidAction("removeWindowListener") {
        @Override
        public void map() {
            ((Window) getSource()).removeWindowListener(windowListener);
        }
    });
}
项目:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud    文件:ChartPanel.java   
public static void viewGraph(int one, int two) {
    JFrame f = new JFrame();
    f.setSize(500, 400);
    f
            .setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    f.setTitle("Group Signature Graph");
    double[] values = new double[2];
    String[] names = new String[2];
    values[0] = one;
    names[0] = "Existed System";

    values[1] = two;
    names[1] = "Praposed System";

    f.getContentPane()
            .add(
                    new ChartPanel(values, names,
                            "Group Signature Genereted Graph"));

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);
}
项目:openjdk9    文件:WindowOperator.java   
/**
 * Maps {@code Window.addWindowListener(WindowListener)} through queue
 */
public void addWindowListener(final WindowListener windowListener) {
    runMapping(new MapVoidAction("addWindowListener") {
        @Override
        public void map() {
            ((Window) getSource()).addWindowListener(windowListener);
        }
    });
}
项目:openjdk9    文件:WindowOperator.java   
/**
 * Maps {@code Window.removeWindowListener(WindowListener)} through queue
 */
public void removeWindowListener(final WindowListener windowListener) {
    runMapping(new MapVoidAction("removeWindowListener") {
        @Override
        public void map() {
            ((Window) getSource()).removeWindowListener(windowListener);
        }
    });
}
项目:hiervis    文件:SwingUIUtils.java   
/**
 * Creates and registers a {@link WindowListener} to {@code window}, which executes the callback expression.
 * 
 * @param window
 *            the window whose closing will cause the callback to be executed.
 * @param callback
 *            the callback to execute when the window closes.
 * @return the created listener
 */
public static WindowListener addCloseCallback( Window window, Runnable callback )
{
    WindowListener listener = new WindowAdapter() {
        @Override
        public void windowClosing( WindowEvent e )
        {
            callback.run();
        }
    };
    window.addWindowListener( listener );
    return listener;
}