java.awt.event.WindowAdapter Java Examples
The following examples show how to use
java.awt.event.WindowAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatVsDogUI.java From Java-Machine-Learning-for-Computer-Vision with MIT License | 6 votes |
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 #2
Source File: GUIFilterConfigDialog.java From PacketProxy with Apache License 2.0 | 6 votes |
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 #3
Source File: ExtractDialog.java From SubTitleSearcher with Apache License 2.0 | 6 votes |
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 #4
Source File: NBodyRunner.java From JPPF with Apache License 2.0 | 6 votes |
/** * 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 #5
Source File: MyFrame.java From JavaGame with MIT License | 6 votes |
/** * ���ش��� */ 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 #6
Source File: GUIDiffDialogParent.java From PacketProxy with Apache License 2.0 | 6 votes |
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 #7
Source File: TableExample2.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: MetalworksFrame.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: ClickableWindow.java From SikuliX1 with MIT License | 6 votes |
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 #10
Source File: OutputViewer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #11
Source File: PlotApplication.java From opt4j with MIT License | 6 votes |
/** * 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 #12
Source File: GoGui.java From FancyBing with GNU General Public License v3.0 | 6 votes |
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 #13
Source File: ERDesignerMainFrame.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 6 votes |
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 #14
Source File: Font2DTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 File: ModelController.java From arcusplatform with Apache License 2.0 | 6 votes |
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 #16
Source File: GoGui.java From FancyBing with GNU General Public License v3.0 | 6 votes |
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 #17
Source File: MyFrame.java From JavaGame with MIT License | 6 votes |
/** * �Զ������ɴ��ڵķ��� * * @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 #18
Source File: MyFrame.java From JavaGame with MIT License | 6 votes |
/** * �Զ������ɴ��ڵķ��� * * @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 #19
Source File: MyFrame.java From JavaGame with MIT License | 6 votes |
/** * ���ش��� */ 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 #20
Source File: MapLayout.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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 #21
Source File: GraphAlgorithmsVisualDebugger.java From ghidra with Apache License 2.0 | 6 votes |
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 #22
Source File: Triangle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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 #23
Source File: OutputViewer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 #24
Source File: TableExample2.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #25
Source File: Font2DTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #26
Source File: VideoDownloadWindow.java From xdm with GNU General Public License v2.0 | 6 votes |
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 #27
Source File: OutputViewer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 File: ProjectAndTaskFilterDialog.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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 #29
Source File: Client.java From JavaGame with MIT License | 6 votes |
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 #30
Source File: TargetFileListFrame.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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); }