List of usage examples for java.awt.event WindowListener WindowListener
WindowListener
From source file:org.jfree.chart.demo.Main_window.java
void jframe_init() { setBounds(50, 50, width, height);//w ww . ja va2s. com setResizable(false); setVisible(true); addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowIconified(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowDeiconified(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowDeactivated(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowClosing(WindowEvent e) { // TODO Auto-generated method stub System.exit(0); socket.close(); if (socket.isAlive() != true) { comport.close(); timer.stop(); rightpanel.close(); } } @Override public void windowClosed(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowActivated(WindowEvent e) { // TODO Auto-generated method stub } }); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel.add(errors); add(panel); }
From source file:de.tor.tribes.ui.algo.SettingsPanel.java
public static void main(String[] args) { try {// www . j a v a 2s .c o m // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Exception e) { } JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final SettingsPanel sp = new SettingsPanel(null); f.add(sp); f.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); f.pack(); f.setVisible(true); }
From source file:cz.alej.michalik.totp.client.AddDialog.java
public AddDialog(final Properties prop) { System.out.println("Pridat novy zaznam"); this.setTitle("Pidat"); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setMinimumSize(new Dimension(600, 150)); this.setLocationByPlatform(true); // Panel pro vytvoen okraj JPanel panel = new JPanel(); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); panel.setLayout(new GridBagLayout()); // Vlastnosti pro popisky GridBagConstraints label = new GridBagConstraints(); label.insets = new Insets(2, 2, 2, 2); label.fill = GridBagConstraints.NONE; label.weightx = 1;/*from w w w . j a va 2 s . c o m*/ // Vlastnosti pro pole GridBagConstraints field = new GridBagConstraints(); field.insets = new Insets(2, 2, 2, 2); field.fill = GridBagConstraints.HORIZONTAL; field.weightx = 10; this.add(panel); // Nastavm ikonu okna try { String path = "/material-design-icons/content/drawable-xhdpi/ic_create_black_48dp.png"; this.setIconImage(Toolkit.getDefaultToolkit().getImage(App.class.getResource(path))); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pole pro pojmenovn zznamu // Ikona ImageIcon icon = null; try { String path = "/material-design-icons/editor/drawable-xhdpi/ic_format_color_text_black_18dp.png"; icon = new ImageIcon(App.class.getResource(path)); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pidn labelu s ikonou a nastavm velikost psma label.gridy = 0; field.gridy = 0; JLabel nameLabel = new JLabel("Nzev: ", icon, JLabel.CENTER); nameLabel.setFont(nameLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(nameLabel, label); // Pole pro jmno final JTextField name = new JTextField(); name.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50)); name.setFont(name.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(name, field); // Pole pro zadn sdlenho hesla // Ikona icon = null; try { String path = "/material-design-icons/hardware/drawable-xhdpi/ic_security_black_18dp.png"; icon = new ImageIcon(App.class.getResource(path)); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pidn labelu s ikonou label.gridy = 1; field.gridy = 1; JLabel secretLabel = new JLabel("Heslo: ", icon, JLabel.CENTER); secretLabel.setFont(secretLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(secretLabel, label); // Pole pro heslo final JTextField secret = new JTextField(); secret.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50)); secret.setFont(secret.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(secret, field); this.setVisible(true); // Akce pro odesln formule ActionListener submit = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { submit(prop, name, secret, false); } }; // Pi stisku klvesy Enter odele formul name.addActionListener(submit); secret.addActionListener(submit); // Pi zmn pole pro heslo se vstup okamit zformtuje final Runnable sanitizer = new Runnable() { @Override public void run() { sanitize(secret); } }; secret.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { } @Override public void insertUpdate(DocumentEvent e) { SwingUtilities.invokeLater(sanitizer); } @Override public void changedUpdate(DocumentEvent e) { } }); // Pi zaven okna odele formul this.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { // Ignorovat } @Override public void windowIconified(WindowEvent e) { // Ignorovat } @Override public void windowDeiconified(WindowEvent e) { // Ignorovat } @Override public void windowDeactivated(WindowEvent e) { // Ignorovat } @Override public void windowClosing(WindowEvent e) { // Odeslat submit(prop, name, secret, true); } @Override public void windowClosed(WindowEvent e) { // Ignorovat } @Override public void windowActivated(WindowEvent e) { // Ignorovat } }); }
From source file:burlov.ultracipher.swing.SwingGuiApplication.java
protected void startup() { initLAF();/*from w ww. j a va 2 s .com*/ mainFrame = new JFrame(getFrameTitle()); mainFrame.setIconImage(getAppIcon().getImage()); mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); instance = this; mainFrame.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { if (canExit()) { exit(); } mainFrame.setVisible(true); } @Override public void windowClosed(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } }); getMainFrame().setJMenuBar(createMenuBar()); getMainFrame().add(mainPanel); restoreWindowState(); mainFrame.setVisible(true); mainPanel.getEditDataPanel().setEditable(false); loadLocalData(); downloadAndMergeData(); mainPanel.init(); }
From source file:com.frochr123.fabqr.gui.FabQRUploadDialog.java
private void initWindowListener() { this.addWindowListener(new WindowListener() { public void windowClosing(WindowEvent e) { closeDialogCleanup();/* www .j ava2 s . c om*/ } public void windowOpened(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowActivated(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } }); }
From source file:org.tros.torgo.ControllerBase.java
/** * Initialize the window. This is called here from run() and not the * constructor so that the Service Provider doesn't load up all of the * necessary resources when the application loads. *//*from w w w . j a v a 2s. c o m*/ private void initSwing() { this.torgoPanel = createConsole((Controller) this); this.torgoCanvas = createCanvas(torgoPanel); //init the GUI w/ the components... Container contentPane = window.getContentPane(); JToolBar tb = createToolBar(); if (tb != null) { contentPane.add(tb, BorderLayout.NORTH); } final java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(NamedWindow.class); if (torgoCanvas != null) { final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, torgoCanvas.getComponent(), torgoPanel.getComponent()); int dividerLocation = prefs.getInt(this.getClass().getName() + "divider-location", window.getWidth() - 300); splitPane.setDividerLocation(dividerLocation); splitPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { prefs.putInt(this.getClass().getName() + "divider-location", splitPane.getDividerLocation()); } }); contentPane.add(splitPane); } else { contentPane.add(torgoPanel.getComponent()); } JMenuBar mb = createMenuBar(); if (mb == null) { mb = new TorgoMenuBar(window, this); } window.setJMenuBar(mb); JMenu helpMenu = new JMenu("Help"); JMenuItem aboutMenu = new JMenuItem("About Torgo"); try { java.util.Enumeration<URL> resources = ClassLoader.getSystemClassLoader() .getResources(ABOUT_MENU_TORGO_ICON); ImageIcon ico = new ImageIcon(resources.nextElement()); aboutMenu.setIcon(ico); } catch (IOException ex) { Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex); } aboutMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { AboutWindow aw = new AboutWindow(); aw.setVisible(true); } }); helpMenu.add(aboutMenu); JMenu vizMenu = new JMenu("Visualization"); for (String name : TorgoToolkit.getVisualizers()) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(name); viz.add(item); vizMenu.add(item); } if (vizMenu.getItemCount() > 0) { mb.add(vizMenu); } mb.add(helpMenu); window.setJMenuBar(mb); window.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } /** * We only care if the window is closing so we can kill the * interpreter thread. * * @param e */ @Override public void windowClosing(WindowEvent e) { stopInterpreter(); } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); }
From source file:uk.co.modularaudio.componentdesigner.ComponentDesigner.java
public void registerCloseAction() throws DatastoreException { mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(new WindowListener() { @Override//from w ww. j a va2s . c o m public void windowClosed(final WindowEvent e) { log.debug("Window closed event received"); } @Override public void windowOpened(final WindowEvent e) { try { log.debug("Window opening event received - setting thread to lowest priority."); ThreadUtils.setCurrentThreadPriority(MAThreadPriority.APPLICATION); if (log.isDebugEnabled()) { log.debug("Now set to " + MAThreadPriority.APPLICATION); } } catch (final Exception ie) { final String msg = "Exception caught setting gui thread priority: " + ie.toString(); log.error(msg, ie); } } @Override public void windowClosing(final WindowEvent e) { log.debug("Window closing event received."); final Action exitAction = mainFrameActions.getExitAction(); final ActionEvent exitActionEvent = new ActionEvent(e.getSource(), e.getID(), ""); exitAction.actionPerformed(exitActionEvent); } @Override public void windowIconified(final WindowEvent e) { } @Override public void windowDeiconified(final WindowEvent e) { } @Override public void windowActivated(final WindowEvent e) { } @Override public void windowDeactivated(final WindowEvent e) { } }); }
From source file:org.opendatakit.briefcase.ui.MainBriefcaseWindow.java
/** * Create the application.//ww w.j a v a 2 s. c o m */ public MainBriefcaseWindow() { frame = new JFrame(); frame.setBounds(100, 100, 680, 595); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); JLabel lblBriefcaseDirectory = new JLabel(MessageStrings.BRIEFCASE_STORAGE_LOCATION); txtBriefcaseDir = new JTextField(); txtBriefcaseDir.setFocusable(false); txtBriefcaseDir.setEditable(false); txtBriefcaseDir.setColumns(10); btnChoose = new JButton("Change..."); btnChoose.addActionListener(new FolderActionListener()); tabbedPane = new JTabbedPane(JTabbedPane.TOP); GroupLayout groupLayout = new GroupLayout(frame.getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout .createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(tabbedPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 628, Short.MAX_VALUE) .addGroup(groupLayout.createSequentialGroup().addComponent(lblBriefcaseDirectory).addGap(18) .addComponent(txtBriefcaseDir, GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE) .addGap(18).addComponent(btnChoose))) .addContainerGap())); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE) .addComponent(txtBriefcaseDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btnChoose).addComponent(lblBriefcaseDirectory)) .addGap(33).addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE) .addContainerGap())); gatherPanel = new PullTransferPanel(transferTerminationFuture); tabbedPane.addTab(PullTransferPanel.TAB_NAME, null, gatherPanel, null); PullTransferPanel.TAB_POSITION = 0; uploadPanel = new PushTransferPanel(transferTerminationFuture); tabbedPane.addTab(PushTransferPanel.TAB_NAME, null, uploadPanel, null); PushTransferPanel.TAB_POSITION = 1; exportPanel = new ExportPanel(exportTerminationFuture); tabbedPane.addTab(ExportPanel.TAB_NAME, null, exportPanel, null); frame.getContentPane().setLayout(groupLayout); ExportPanel.TAB_POSITION = 2; frame.addWindowListener(this); setFullUIEnabled(false); frame.setFocusTraversalPolicy(new FocusTraversalPolicy() { @Override public Component getComponentAfter(Container arg0, Component arg1) { ArrayList<Component> componentOrdering = new ArrayList<Component>(); for (;;) { int nextPanel = PullTransferPanel.TAB_POSITION; componentOrdering.clear(); componentOrdering.add(txtBriefcaseDir); componentOrdering.add(btnChoose); componentOrdering.add(tabbedPane); int idx = tabbedPane.getSelectedIndex(); if (idx == PullTransferPanel.TAB_POSITION) { componentOrdering.addAll(gatherPanel.getTraversalOrdering()); nextPanel = PushTransferPanel.TAB_POSITION; } else if (idx == PushTransferPanel.TAB_POSITION) { componentOrdering.addAll(uploadPanel.getTraversalOrdering()); nextPanel = ExportPanel.TAB_POSITION; } else if (idx == ExportPanel.TAB_POSITION) { componentOrdering.addAll(exportPanel.getTraversalOrdering()); nextPanel = PullTransferPanel.TAB_POSITION; } componentOrdering.add(btnChoose); boolean found = false; for (int i = 0; i < componentOrdering.size() - 1; ++i) { if (found || arg1 == componentOrdering.get(i)) { found = true; Component comp = componentOrdering.get(i + 1); if (comp == tabbedPane) { return comp; } if (comp.isVisible() && comp.isEnabled() && (!(comp instanceof JTextField) || ((JTextField) comp).isEditable())) { return comp; } } } if (!found) { return componentOrdering.get(0); } tabbedPane.setSelectedIndex(nextPanel); } } @Override public Component getComponentBefore(Container arg0, Component arg1) { ArrayList<Component> componentOrdering = new ArrayList<Component>(); for (;;) { int nextPanel = PullTransferPanel.TAB_POSITION; componentOrdering.clear(); componentOrdering.add(txtBriefcaseDir); componentOrdering.add(btnChoose); componentOrdering.add(tabbedPane); int idx = tabbedPane.getSelectedIndex(); if (idx == PullTransferPanel.TAB_POSITION) { componentOrdering.addAll(gatherPanel.getTraversalOrdering()); nextPanel = ExportPanel.TAB_POSITION; } else if (idx == PushTransferPanel.TAB_POSITION) { componentOrdering.addAll(uploadPanel.getTraversalOrdering()); nextPanel = PullTransferPanel.TAB_POSITION; } else if (idx == ExportPanel.TAB_POSITION) { componentOrdering.addAll(exportPanel.getTraversalOrdering()); nextPanel = PushTransferPanel.TAB_POSITION; } componentOrdering.add(btnChoose); boolean found = false; for (int i = componentOrdering.size() - 1; i > 0; --i) { if (found || arg1 == componentOrdering.get(i)) { found = true; Component comp = componentOrdering.get(i - 1); if (comp == tabbedPane) { return comp; } if (comp.isVisible() && comp.isEnabled() && (!(comp instanceof JTextField) || ((JTextField) comp).isEditable())) { return comp; } } } if (!found) { return componentOrdering.get(componentOrdering.size() - 1); } tabbedPane.setSelectedIndex(nextPanel); } } @Override public Component getDefaultComponent(Container arg0) { return btnChoose; } @Override public Component getFirstComponent(Container arg0) { return btnChoose; } @Override public Component getLastComponent(Container arg0) { return tabbedPane; } }); }
From source file:org.richie.codeGen.ui.CodeGenMainUI.java
public void addCloseListener() { this.addWindowListener(new WindowListener() { @Override/*from www. j a v a 2 s. c o m*/ public void windowOpened(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { getGenAndPreviewPanel().saveLastTemplate(); } @Override public void windowClosed(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } }); }
From source file:com.qspin.qtaste.ui.MainPanel.java
protected void genMenu(final TestCaseTree tct) { final JFrame owner = this; JMenuBar menuBar = new JMenuBar(); JMenu tools = new JMenu("Tools"); tools.setMnemonic(KeyEvent.VK_T); // Tools|Config menu item JMenuItem config = new JMenuItem("Config", KeyEvent.VK_D); config.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //ATEConfigEditPanel configPanel = new ATEConfigEditPanel(null); //configPanel.setVisible(true); MainConfigFrame configFrame = new MainConfigFrame(); configFrame.launch();/*from w ww . j av a2s. co m*/ configFrame.addWindowListener(new WindowListener() { public void windowOpened(WindowEvent e) { } public void windowClosing(WindowEvent e) { } public void windowClosed(WindowEvent e) { // refresh the Configuration information display refreshParams(); } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowActivated(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } }); } }); tools.add(config); // Tools|delete results menu item JMenuItem deleteResults = new JMenuItem("Delete Results", KeyEvent.VK_D); final MainPanel ui = this; deleteResults.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String baseDir = TestEngineConfiguration.getInstance().getString("reporting.generated_report_path"); new File(baseDir, baseDir); // TO DO : delete really the files JOptionPane.showMessageDialog(ui, "Results have been deleted"); } }); tools.add(deleteResults); JMenu fileMenu = new JMenu("File"); JMenuItem importTestSuites = new JMenuItem("Import TestSuites"); importTestSuites.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // mTestCasePanel.importTestSuites(); } }); fileMenu.add(importTestSuites); JMenu help = new JMenu("Help"); help.setMnemonic(KeyEvent.VK_H); JMenuItem about = new JMenuItem("About", KeyEvent.VK_A); about.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutDialog(owner); } }); help.add(about); JMenuItem ateUserManuel = new JMenuItem("User Manual"); ateUserManuel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewQTasteUserManuel(); } }); help.add(ateUserManuel); //menuBar.add(tools); // not to be used at this time!!!!!!!!! //menuBar.add(fileMenu); menuBar.add(help); setJMenuBar(menuBar); }