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

RevisionPicker.java 文件源码 项目:incubator-netbeans 阅读 31 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:OpenJSharp 阅读 31 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:jdk8u-jdk 阅读 30 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:openjdk-jdk10 阅读 30 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:openjdk9 阅读 33 收藏 0 点赞 0 评论 0
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;
}
SwingUIUtils.java 文件源码 项目:hiervis 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 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
                )
            );
        }
    );
}
JOptionPane.java 文件源码 项目:Java8CN 阅读 35 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:jdk8u_jdk 阅读 33 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 31 收藏 0 点赞 0 评论 0
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;
}
Run.java 文件源码 项目:GArduino 阅读 35 收藏 0 点赞 0 评论 0
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);

   }
SwingSet2.java 文件源码 项目:beautyeye 阅读 37 收藏 0 点赞 0 评论 0
/**
 * 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;
}
JCalendarDemo.java 文件源码 项目:fil_project_mgmt_app_v2 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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);
}
WindowFactory.java 文件源码 项目:java-ui-factory 阅读 38 收藏 0 点赞 0 评论 0
@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());
    }
}
JOptionPane.java 文件源码 项目:infobip-open-jdk-8 阅读 31 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:jdk8u-dev-jdk 阅读 32 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:jdk7-jdk 阅读 33 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:openjdk-source-code-learn 阅读 39 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:OLD-OpenJDK8 阅读 34 收藏 0 点赞 0 评论 0
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;
}
HorizontalBarGraph.java 文件源码 项目:BamQC 阅读 30 收藏 0 点赞 0 评论 0
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);
}
JOptionPane.java 文件源码 项目:openjdk-jdk7u-jdk 阅读 30 收藏 0 点赞 0 评论 0
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;
}
JCalendarDemo.java 文件源码 项目:JCalendar 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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);
}
JideApplicationWindow.java 文件源码 项目:spring-rich-client 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 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;
    }
}
Client.java 文件源码 项目:cloudstack 阅读 39 收藏 0 点赞 0 评论 0
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;
}
JOptionPane.java 文件源码 项目:openjdk-icedtea7 阅读 30 收藏 0 点赞 0 评论 0
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;
}
GridProxyInit.java 文件源码 项目:cagrid-general 阅读 36 收藏 0 点赞 0 评论 0
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);
   }
JideApplicationWindow.java 文件源码 项目:spring-richclient 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 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;
    }
}
Modules.java 文件源码 项目:eXamine 阅读 31 收藏 0 点赞 0 评论 0
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);
}
PopupHelper.java 文件源码 项目:org.datagr4m 阅读 35 收藏 0 点赞 0 评论 0
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;
}
Main.java 文件源码 项目:NK-VirtualGlobe 阅读 31 收藏 0 点赞 0 评论 0
/** 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]);
    }
}
Main.java 文件源码 项目:NK-VirtualGlobe 阅读 31 收藏 0 点赞 0 评论 0
/** 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);
}


问题


面经


文章

微信
公众号

扫码关注公众号