List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:es.emergya.ui.base.plugins.DetachedTab.java
/** * @param original_pane/* w ww. j a va2 s. co m*/ * @param title * @param tip * @param original_positon * @param detached_tab * @param icon * @throws HeadlessException */ public DetachedTab(PluggableJTabbedPane original_pane, String title, String tip, int original_positon, Component detached_tab, Icon icon) throws HeadlessException { super(title); this.setIconImage(window.getFrame().getIconImage()); this.original_pane = original_pane; this.tip = tip; this.original_positon = original_positon; this.detached_tab = detached_tab; this.icon = icon; this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (retatch_on_close) { DetachedTab.this.original_pane.reattach(DetachedTab.this); DetachedTab.this.dispose(); } Authentication.logOut(); super.windowClosing(e); } }); addTab(detached_tab.getName(), icon, detached_tab); this.addWindowListener(new WindowAdapter() { }); this.setMinimumSize(new Dimension(800, 600)); // this.addComponentListener(new ComponentAdapter() { // @Override // public void componentResized(ComponentEvent e) { // super.componentResized(e); // Dimension d = DetachedTab.this.getSize(); // DetachedTab.log.info("Size actual: " + d); // if (d.width < 800) // d.width = 800; // if (d.height < 200) // d.height = 200; // DetachedTab.log.info("Size after: " + d); // DetachedTab.this.setSize(d.width, d.height); // } // }); this.add(pane); pack(); this.setExtendedState(JFrame.MAXIMIZED_BOTH); }
From source file:client.gui.ConnectionDialog.java
public ConnectionDialog() { connect = new JButton("Connect"); connectDev = new JButton("Connect (Developer)"); connectSame = new JButton("Connect (a as nick)"); nick = new JTextField(); host = new JTextField(); port = new JTextField(); setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); setSize(new Dimension(400, 200)); host.setPreferredSize(new Dimension(200, 24)); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.0;/* w ww . java 2 s.c o m*/ c.gridx = 0; c.gridy = 0; add(new JLabel("Nick:"), c); c.gridy = 1; add(new JLabel("Host:"), c); c.gridy = 2; add(new JLabel("Port:"), c); c.gridx = 1; c.gridy = 0; add(nick, c); c.gridy = 1; add(host, c); c.gridy = 2; add(port, c); c.gridx = 0; c.gridy = 3; c.gridwidth = 2; add(connect, c); // c.gridy = 4; // add(connectDev, c); // c.gridy = 5; // add(connectSame, c); connect.addActionListener(this); connectDev.addActionListener(this); connectSame.addActionListener(this); addWindowListener(new WindowAdapter() { public void windowClosing(final WindowEvent event) { dispose(); } }); final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2); }
From source file:edu.uchc.octane.OctanePlugin.java
/** * Display particle analysis dialog and start particle analysis * @return True if user clicked OK /*from w w w. j a va 2s . c o m*/ */ boolean startImageAnalysis(String cmd) { dict_.put(imp_, null); if (cmd.equals("analyze2D")) { dlg_ = new ParticleAnalysisDialog2D(imp_); } else if (cmd.equals("analyze3D")) { dlg_ = new ParticleAnalysisDialogAstigmatism(imp_); } else if (cmd.equals("calibration")) { dlg_ = new CalibrationDialogAstigmatism(imp_); } else { return false; } imp_.getWindow().addWindowListener(new WindowAdapter() { boolean wasVisible; @Override public void windowIconified(WindowEvent e) { wasVisible = dlg_.isVisible(); dlg_.setVisible(false); } @Override public void windowDeiconified(WindowEvent e) { if (dlg_.isDisplayable()) { dlg_.setVisible(wasVisible); } } @Override public void windowClosed(WindowEvent e) { dlg_.dispose(); } }); dlg_.showDialog(); return dlg_.wasOKed(); }
From source file:javaapplication3.ObjetDialog.java
public void ObjetDialogStart() { instance = new InstanceCall(); setTitle("Add Information about" + new File(BPath.getText()).getName()); hideErrorFields();//from w ww. j a v a 2 s . c om Date date = Calendar.getInstance().getTime(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); this.dateRunTxt.setText(sdf.format(date)); this.setLocationRelativeTo(null); //search database for buildName //File BPathfile = new File(BPath.getText().replace("\\", "\\\\")); setVisible(true); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { String ObjButtons[] = { "Yes", "No" }; int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]); if (PromptResult == JOptionPane.YES_OPTION) { gatherScrapThenExit(); PrinterBuild.selectAllFiles("Objet"); dispose(); } else { ResultSet r = ObjetMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName()); try { while (r.next()) { ObjetMain.dba.updatePendingJobsBuildName(r.getString("buildName"), r.getString("fileName")); } } catch (SQLException ex) { Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex); } ResultSet s = ObjetMain.dba.searchObjetByBuildName(new File(BPath.getText()).getName()); try { while (s.next()) { ObjetMain.dba.deleteByBuildName(s.getString("buildName"), "objet"); } } catch (SQLException ex) { Logger.getLogger(ObjetDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } } }); }
From source file:javaapplication3.ZCorpDialog.java
public void ZCorpDialogStart() { instance = new InstanceCall(); setTitle("Add Information about" + new File(BPath.getText()).getName()); hideErrorFields();// www . ja v a2s .c om Date date = Calendar.getInstance().getTime(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); this.dateRunTxt.setText(sdf.format(date)); this.setLocationRelativeTo(null); //search database for buildName //File BPathfile = new File(BPath.getText().replace("\\", "\\\\")); setVisible(true); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { String ObjButtons[] = { "Yes", "No" }; int PromptResult = JOptionPane.showOptionDialog(null, "Save as an Open Build?", "Save", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, ObjButtons, ObjButtons[1]); if (PromptResult == JOptionPane.YES_OPTION) { gatherScrapThenExit(); PrinterBuild.selectAllFiles("ZCorp"); dispose(); } else { ResultSet r = ZCorpMain.dba.searchPendingByBuildName(new File(BPath.getText()).getName()); try { while (r.next()) { ZCorpMain.dba.updatePendingJobsBuildName(r.getString("buildName"), r.getString("fileName")); } } catch (SQLException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } ResultSet s = ZCorpMain.dba.searchZCorpByBuildName(new File(BPath.getText()).getName()); try { while (s.next()) { ZCorpMain.dba.deleteByBuildName(s.getString("buildName"), "zcorp"); } } catch (SQLException ex) { Logger.getLogger(ZCorpDialog.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } } }); }
From source file:com.wafflesoft.kinectcontroller.Main.java
public void run() { KinectUserTracker kinectUserTracker = new KinectUserTracker(_csm); _done = false;/*from ww w . j a v a 2 s . co m*/ _frame = new JFrame("Kinect Controller"); // register to key events _frame.addKeyListener(new KeyListener() { public void keyTyped(KeyEvent arg) { } public void keyReleased(KeyEvent arg) { } public void keyPressed(KeyEvent arg) { if (arg.getKeyCode() == KeyEvent.VK_ESCAPE) { _done = true; } } }); // register to closing event _frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { _done = true; } }); kinectUserTracker.kinectWindow.setSize(800, 600); _frame.add("Center", kinectUserTracker.kinectWindow); _eventWindow = new JTextArea(); _eventWindow.setVisible(!_arguments.hasOption('d')); _frame.add(new JScrollPane(_eventWindow)); _frame.setSize(kinectUserTracker.kinectWindow.getWidth(), kinectUserTracker.kinectWindow.getHeight()); _frame.setVisible(true); while (!_done) { _frame.repaint(); try { Thread.sleep(16); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:assign3.client.WaypointClient.java
public WaypointClient(String base, String hostId, String port) throws RemoteException { super(base);//from w ww . j a va 2s .c om this.hostId = hostId; this.port = port; removeWPButt.addActionListener(this); addWPButt.addActionListener(this); modWPButt.addActionListener(this); exportToJSON.addActionListener(this); distBearButt.addActionListener(this); frWps.addItemListener(this); toWps.addItemListener(this); try { server = (WaypointServer) Naming.lookup("rmi://" + hostId + ":" + port + "/WaypointServer"); System.out.println("Client obtained remote object reference to" + " the WaypointServer at:\n" + "rmi://" + hostId + ":" + port + "/WaypointServer"); } catch (Exception e) { System.out.println("Could not find server."); } System.out.println("Getting Waypoints From Server."); String[] names = server.getNames(); for (int i = 0; i < names.length; i++) { Waypoint aWp = server.get(names[i]); frWps.addItem(names[i]); toWps.addItem(names[i]); System.out.println(names[i]); } this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { debug("you clicked X"); System.exit(0); } }); setVisible(true); }
From source file:support.TradingVolumeGui.java
private CategoryPlot createChartFrame(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Trading Volume", "Stock", "Volume, USD", dataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.setVisible(true);/*from w w w. j av a 2s.co m*/ frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { hzMap.removeEntryListener(entryListenerId); } }); return plot; }
From source file:com.mirth.connect.connectors.jdbc.DatabaseMetadataDialog.java
public DatabaseMetadataDialog(ConnectorSettingsPanel parentConnector, STATEMENT_TYPE type, DatabaseConnectionInfo databaseConnectionInfo) { super(PlatformUI.MIRTH_FRAME); this.parent = PlatformUI.MIRTH_FRAME; this.parentConnector = parentConnector; this.type = type; initComponents();/*from www .j a v a 2s.c o m*/ this.databaseConnectionInfo = databaseConnectionInfo; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { cancelButtonActionPerformed(null); } }); setModal(true); pack(); Dimension dlgSize = getPreferredSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { setLocationRelativeTo(null); } else { setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } makeIncludedMetaDataTable(null); filterTableTextField.requestFocus(); setVisible(true); }
From source file:components.CustomDialog.java
/** Creates the reusable dialog. */ public CustomDialog(Frame aFrame, String aWord, DialogDemo parent) { super(aFrame, true); dd = parent;/*w w w. ja v a 2 s.c o m*/ magicWord = aWord.toUpperCase(); setTitle("Quiz"); textField = new JTextField(10); //Create an array of the text and components to be displayed. String msgString1 = "What was Dr. SEUSS's real last name?"; String msgString2 = "(The answer is \"" + magicWord + "\".)"; Object[] array = { msgString1, msgString2, textField }; //Create an array specifying the number of dialog buttons //and their text. Object[] options = { btnString1, btnString2 }; //Create the JOptionPane. optionPane = new JOptionPane(array, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); //Make this dialog display it. setContentPane(optionPane); //Handle window closing correctly. setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { /* * Instead of directly closing the window, * we're going to change the JOptionPane's * value property. */ optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION)); } }); //Ensure the text field always gets the first focus. addComponentListener(new ComponentAdapter() { public void componentShown(ComponentEvent ce) { textField.requestFocusInWindow(); } }); //Register an event handler that puts the text into the option pane. textField.addActionListener(this); //Register an event handler that reacts to option pane state changes. optionPane.addPropertyChangeListener(this); }