Java Code Examples for java.awt.event.WindowAdapter

The following examples show how to use java.awt.event.WindowAdapter. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: FancyBing   Source File: GoGui.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void createTree()
{
    m_gameTreeViewer = new GameTreeViewer(this, this, m_messageDialogs);
    m_gameTreeViewer.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                actionDisposeTree();
            }
        });
    GuiAction.registerAll(m_gameTreeViewer.getLayeredPane());
    m_gameTreeViewer.setLabelMode(m_treeLabels);
    m_gameTreeViewer.setSizeMode(m_treeSize);
    m_gameTreeViewer.setShowSubtreeSizes(m_showSubtreeSizes);
    restoreSize(m_gameTreeViewer, "tree");
    m_gameTreeViewer.update(getTree(), getCurrentNode());
    m_gameTreeViewer.setVisible(true);
}
 
Example 2
Source Project: PacketProxy   Source File: GUIDiffDialogParent.java    License: Apache License 2.0 6 votes vote down vote up
public GUIDiffDialogParent(JFrame owner) throws Exception {
	super(owner);
	setTitle("Diff");

	Rectangle rect = owner.getBounds();
	width = rect.width - 100;
	height = rect.height - 100;
	setBounds(rect.x + rect.width/2 - width/2, rect.y + rect.height/2 - height/2, width, height); /* ド真ん中 */

	createPanel();
	Container c = getContentPane();
	c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
	c.add(main_panel);

	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent event) {
			try {
				dispose();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}
 
Example 3
Source Project: PacketProxy   Source File: GUIFilterConfigDialog.java    License: Apache License 2.0 6 votes vote down vote up
public GUIFilterConfigDialog(JFrame owner) throws Exception {
	super(owner);
	this.owner = owner;
	setTitle(I18nString.get("Manage filters"));
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
    		dispose();
		}
	});
	
	Rectangle rect = owner.getBounds();
	setBounds(rect.x + rect.width/2 - width/2, rect.y + rect.height/2 - height/2, width, height); /* ド真ん中 */

	Container c = getContentPane();
	JPanel panel = new JPanel(); 
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(new GUIFilterConfig(owner).createPanel());
	c.add(panel);

}
 
Example 4
Source Project: SubTitleSearcher   Source File: ExtractDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void initComponents() {
	ExtractDialog _this = this;
	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	// setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	setIconImage(MainWin.icon);
	setSize(820, 460);
	// setResizable(false);

	setLocationRelativeTo(this.getParent());
	setTitle("请选择压缩包中要保存的字幕文件");

	this.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			_this.clear();
			_this.dispose();
		}
	});

	add(bsPanel, BorderLayout.CENTER);
	openUrl(MainWin.class.getResource("/html/extract_dialog.html").toExternalForm());

}
 
Example 5
Source Project: JPPF   Source File: NBodyRunner.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create the UI.
 * @throws Exception if any error occurs.
 */
private static void createUI() throws Exception {
  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  final JFrame frame = new JFrame("N-Body demo");
  frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(final WindowEvent e) {
      System.exit(0);
    }
  });
  final JPanel topPanel = new JPanel();
  label = new JLabel("Time steps: 0");
  label.setHorizontalAlignment(SwingConstants.LEFT);
  label.setAlignmentX(0f);
  topPanel.add(label, BorderLayout.WEST);
  frame.getContentPane().add(topPanel, BorderLayout.NORTH);
  panel = new NBodyPanel();
  final Dimension dim = new Dimension((int) radius, (int) radius);
  panel.setMinimumSize(dim);
  panel.setMaximumSize(dim);
  panel.setPreferredSize(dim);
  frame.getContentPane().add(panel, BorderLayout.CENTER);
  frame.setSize((int) radius + 50, (int) radius + 70);
  frame.setVisible(true);
}
 
Example 6
public ERDesignerMainFrame() {
    super(ERDesignerBundle.TITLE);

    initialize();

    setSize(800, 600);
    setExtendedState(MAXIMIZED_BOTH);
    setIconImage(IconFactory.getERDesignerIcon().getImage());

    addWindowListener(new WindowAdapter() {

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

    UIInitializer.getInstance().initialize(this);
    initTitle();
}
 
Example 7
Source Project: JavaGame   Source File: MyFrame.java    License: MIT License 6 votes vote down vote up
/**
 * ���ش���
 */
public void loadFrame(){
	this.setTitle("����˹����");
	this.setSize(Constant.FRAME_WIDTH, Constant.FRAME_HEIGHT);
	this.setBackground(Color.WHITE);
	this.setLocationRelativeTo(null);//����
	this.setResizable(false);
	this.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	this.setVisible(true);
	
	new MyThread().start();
}
 
Example 8
Source Project: JavaGame   Source File: Client.java    License: MIT License 6 votes vote down vote up
public void loadFrame() {
	initRandomTree();
	this.setTitle("����");
	this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
	this.setBackground(Color.WHITE);
	this.setLocationRelativeTo(null);// ����
	this.setResizable(false);
	this.setFont(new Font("��Բ", Font.BOLD, 20));
	this.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	this.setLayout(null);
	this.initComponent();// ��ʼ�����
	this.setVisible(true);
}
 
Example 9
Source Project: JavaGame   Source File: MyFrame.java    License: MIT License 6 votes vote down vote up
/**
 * �Զ������ɴ��ڵķ���
 * 
 * @throws InterruptedException
 */
public void launchFrame() {
	// ���ô��ڴ�С
	setSize(Constant.GAME_WIDTH, Constant.GAME_HEIGHT);
	// ���ô���λ��
	// setLocation(0, 0);
	setLocationRelativeTo(null);// ��Ծ��У�����null���������ʾ����Ļ
	// ���ô��ڱ���
	setTitle("�ɻ���ս");
	// ���ÿɼ�
	setVisible(true);
	// ���ò��ܸı��С
	setResizable(false);
	// ���ùرմ���
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			System.exit(0);// ���ùر�
		}
	});
	enableInputMethods(false);//�������뷨
	setBackground(Color.BLACK);

	new MyThread().start();

}
 
Example 10
Source Project: JavaGame   Source File: MyFrame.java    License: MIT License 6 votes vote down vote up
/**
 * �Զ������ɴ��ڵķ���
 * 
 * @throws InterruptedException
 */
public void launchFrame() {
	// ���ô��ڴ�С
	setSize(Constant.GAME_WIDTH, Constant.GAME_HEIGHT);
	// ���ô���λ��
	// setLocation(0, 0);
	setLocationRelativeTo(null);// ��Ծ��У�����null���������ʾ����Ļ
	// ���ô��ڱ���
	setTitle("�ɻ���ս(�޾���)");
	// ���ÿɼ�
	setVisible(true);
	// ���ò��ܸı��С
	setResizable(false);
	// ���ùرմ���
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			System.exit(0);// ���ùر�
		}
	});
	enableInputMethods(false);//�������뷨
	setBackground(Color.BLACK);

	new MyThread().start();

}
 
Example 11
Source Project: JavaGame   Source File: MyFrame.java    License: MIT License 6 votes vote down vote up
/**
 * ���ش���
 */
public void loadFrame(){
	this.setTitle("����˹����");
	this.setSize(Constant.FRAME_WIDTH, Constant.FRAME_HEIGHT);
	this.setBackground(Color.WHITE);
	this.setLocationRelativeTo(null);//����
	this.setResizable(false);
	this.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	this.setVisible(true);
	new MyThread().start();
}
 
Example 12
Source Project: MeteoInfo   Source File: MapLayout.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 13
Source Project: MeteoInfo   Source File: Triangle.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

        final GLProfile gp = GLProfile.get(GLProfile.GL2);
        GLCapabilities cap = new GLCapabilities(gp);

        final GLCanvas gc = new GLCanvas(cap);
        Triangle tr = new Triangle();
        gc.addGLEventListener(tr);
        gc.setSize(400, 400);

        final JFrame frame = new JFrame("JOGL Triangle");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent windowevent) {
                frame.dispose();
                System.exit(0);
            }
        });
        frame.add(gc);
        frame.setSize(500, 400);
        frame.setVisible(true);
    }
 
Example 14
Source Project: dragonwell8_jdk   Source File: Font2DTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
    }
}
 
Example 15
Source Project: dragonwell8_jdk   Source File: OutputViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void append(String s) {
    if (frame == null) {
        // FIXME: The frame title should be a localized string.
        frame = new JFrame("JConsole: Output");
        ta = new JTextArea();
        ta.setEditable(false);
        frame.getContentPane().add(new JScrollPane(ta));
        ta.setFont(new Font("Monospaced", Font.BOLD, 14));
        frame.setSize(500, 600);
        frame.setLocation(1024-500, 768-600);
        // Exit JConsole if no window remains.
        // e.g. jconsole -version only creates the OutputViewer
        // but no other window.
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (JFrame.getFrames().length == 1) {
                    System.exit(0);
                }
            }
        });
    }
    ta.append(s);
    ta.setCaretPosition(ta.getText().length());
    frame.setVisible(true);
}
 
Example 16
private JFrame createMainFrame() {
    JFrame mainFrame = new JFrame();
    mainFrame.setTitle("Image Recognizer");
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            System.exit(0);
        }
    });
    ImageIcon imageIcon = new ImageIcon("icon.png");
    mainFrame.setIconImage(imageIcon.getImage());

    return mainFrame;
}
 
Example 17
Source Project: ghidra   Source File: GraphAlgorithmsVisualDebugger.java    License: Apache License 2.0 6 votes vote down vote up
private TestGraphAlgorithmSteppingViewerPanel<TestV, TestE> showViewer(
		AlgorithmSteppingTaskMonitor steppingMonitor) {

	String isHeadless = Boolean.toString(false);
	System.setProperty(SystemUtilities.HEADLESS_PROPERTY, isHeadless);
	System.setProperty("java.awt.headless", isHeadless);

	JFrame frame = new JFrame("Graph");
	TestGraphAlgorithmSteppingViewerPanel<TestV, TestE> gp =
		new TestGraphAlgorithmSteppingViewerPanel<>(g, steppingMonitor);
	frame.getContentPane().add(gp);
	frame.setSize(800, 800);
	frame.setVisible(true);

	frame.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			steppingMonitor.cancel();
		}
	});

	return gp;
}
 
Example 18
Source Project: FancyBing   Source File: GoGui.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void createAnalyzeDialog()
{
    m_analyzeDialog = new AnalyzeDialog(this, this, m_analyzeCommands,
                                        m_gtp, m_messageDialogs);
    m_analyzeDialog.setReuseTextWindow(
                    m_prefs.getBoolean("analyze-reuse-text-window", false));
    GuiAction.registerAll(m_analyzeDialog.getLayeredPane());
    m_analyzeDialog.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                actionDisposeAnalyzeDialog();
            }
        });
    m_analyzeDialog.setBoardSize(getBoardSize());
    m_analyzeDialog.setSelectedColor(getToMove());
    restoreSize(m_analyzeDialog, "analyze");
    m_analyzeDialog.setVisible(true);
}
 
Example 19
Source Project: arcusplatform   Source File: ModelController.java    License: Apache License 2.0 6 votes vote down vote up
public Window show(Model model) {
   Window window = windows.computeIfAbsent(model.getAddress(), (address) -> {
      ModelTableView view = new ModelTableView();
      view.bind(new DefaultSelectionModel<Model>(model));
      
      JDialog dialog = new JDialog(null, model.getAddress(), ModalityType.MODELESS);
      dialog.add(new JScrollPane(view.getComponent()));
      dialog.setSize(600, 400);
      dialog.addWindowListener(new WindowAdapter() {
         /* (non-Javadoc)
          * @see java.awt.event.WindowAdapter#windowClosed(java.awt.event.WindowEvent)
          */
         @Override
         public void windowClosed(WindowEvent e) {
            view.dispose();
         }
      });
      
      return dialog;
   });
   window.setVisible(true);
   return window;
}
 
Example 20
Source Project: TencentKona-8   Source File: TableExample2.java    License: GNU General Public License v2.0 6 votes vote down vote up
public TableExample2(String URL, String driver, String user,
        String passwd, String query) {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
    dt.executeQuery(query);

    // Create the table
    JTable tableView = new JTable(dt);

    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setPreferredSize(new Dimension(700, 300));

    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);
}
 
Example 21
public MetalworksFrame() {
    super("Metalworks");
    final int inset = 50;
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds(inset, inset, screenSize.width - inset * 2, screenSize.height - inset
            * 2);
    buildContent();
    buildMenus();
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            quit();
        }
    });
    UIManager.addPropertyChangeListener(new UISwitchListener(
            (JComponent) getRootPane()));
}
 
Example 22
Source Project: SikuliX1   Source File: ClickableWindow.java    License: MIT License 6 votes vote down vote up
public ClickableWindow(Guide guide) {
  super(new Color(0.1f, 0f, 0f, 0.005f), null);
  this.guide = guide;

  jp = getJPanel();

  mouseTracker = GlobalMouseMotionTracker.getInstance();
  mouseTracker.addListener(this);

  setVisible(false);
  setFocusableWindowState(false);

  addMouseListener(this);

  addWindowListener(new WindowAdapter() {
    public void windowClosed(WindowEvent e) {
      // stop the global mouse tracker's timer thread
      mouseTracker.stop();
    }
  });
}
 
Example 23
Source Project: opt4j   Source File: PlotApplication.java    License: MIT License 6 votes vote down vote up
/**
 * Display the given plot. Unlike the two argument constructor, this does
 * not take command-line arguments, and does not fill the plot with a sample
 * plot.
 * 
 * @param plot
 *            The instance of Plot to display.
 */
public PlotApplication(PlotBox plot) {
	// Invoke the base class constructor and pass in the argument a Plot
	// object. This makes sure that the plot field is an instance of
	// Plot class.
	super("PlotApplication", plot);

	// Handle window closing by exiting the application.
	addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			// Strangely, calling _close() here sends javac into
			// an infinite loop (in jdk 1.1.4).
			// _close();
			System.exit(0);
		}
	});

	setVisible(true);
}
 
Example 24
Source Project: xdm   Source File: VideoDownloadWindow.java    License: GNU General Public License v2.0 6 votes vote down vote up
public VideoDownloadWindow(HttpMetadata metadata, String file) {
	// this.folder = Config.getInstance().getDownloadFolder();
	this.metadata = metadata;
	if (this.metadata == null) {
		this.metadata = new HttpMetadata();
	}

	initUI();

	if (file != null && file.length() > 0) {
		filePane.setFileName(file);
		// txtFile.setCaretPosition(0);
		originalExt = XDMUtils.getExtension(filePane.getFileName());
	}

	getRootPane().setDefaultButton(btnDN);

	addWindowListener(new WindowAdapter() {
		@Override
		public void windowActivated(WindowEvent e) {
			filePane.setFocus();
		}
	});

	queueId = "";
}
 
Example 25
private void setupUI() {
    mainPanel = new JPanel(new BorderLayout());
    dialog.getContentPane().add(mainPanel);

    mainPanel.add(createOptionsPanel(), BorderLayout.NORTH);
    mainPanel.add(createCenterPanel(), BorderLayout.CENTER);
    mainPanel.add(createOkCancelPanel(), BorderLayout.SOUTH);

    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            close(false);
        }
    });

    dialog.setSize(600, 750);
    dialog.setLocationRelativeTo(dialog.getParent());
}
 
Example 26
Source Project: jdk8u60   Source File: TableExample2.java    License: GNU General Public License v2.0 6 votes vote down vote up
public TableExample2(String URL, String driver, String user,
        String passwd, String query) {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
    dt.executeQuery(query);

    // Create the table
    JTable tableView = new JTable(dt);

    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setPreferredSize(new Dimension(700, 300));

    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);
}
 
Example 27
Source Project: openjdk-jdk8u   Source File: OutputViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void append(String s) {
    if (frame == null) {
        // FIXME: The frame title should be a localized string.
        frame = new JFrame("JConsole: Output");
        ta = new JTextArea();
        ta.setEditable(false);
        frame.getContentPane().add(new JScrollPane(ta));
        ta.setFont(new Font("Monospaced", Font.BOLD, 14));
        frame.setSize(500, 600);
        frame.setLocation(1024-500, 768-600);
        // Exit JConsole if no window remains.
        // e.g. jconsole -version only creates the OutputViewer
        // but no other window.
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (JFrame.getFrames().length == 1) {
                    System.exit(0);
                }
            }
        });
    }
    ta.append(s);
    ta.setCaretPosition(ta.getText().length());
    frame.setVisible(true);
}
 
Example 28
Source Project: jdk8u60   Source File: Font2DTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
    }
}
 
Example 29
Source Project: jdk8u60   Source File: OutputViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void append(String s) {
    if (frame == null) {
        // FIXME: The frame title should be a localized string.
        frame = new JFrame("JConsole: Output");
        ta = new JTextArea();
        ta.setEditable(false);
        frame.getContentPane().add(new JScrollPane(ta));
        ta.setFont(new Font("Monospaced", Font.BOLD, 14));
        frame.setSize(500, 600);
        frame.setLocation(1024-500, 768-600);
        // Exit JConsole if no window remains.
        // e.g. jconsole -version only creates the OutputViewer
        // but no other window.
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (JFrame.getFrames().length == 1) {
                    System.exit(0);
                }
            }
        });
    }
    ta.append(s);
    ta.setCaretPosition(ta.getText().length());
    frame.setVisible(true);
}
 
Example 30
public GLVisualProcessorDemo() {
    frame = new Frame("JOGL Tester");
    frame.setSize(1920, 1080);
    frame.setResizable(false);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            frame.dispose();
            System.exit(0);
        }
    });
}