List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:com.mirth.connect.client.ui.ChangePasswordDialog.java
public ChangePasswordDialog(User currentUser, String message) { super(PlatformUI.MIRTH_FRAME); this.currentUser = currentUser; this.parent = PlatformUI.MIRTH_FRAME; initComponents();//from ww w .ja v a 2 s .com mirthHeadingLabel.setForeground(UIConstants.HEADER_TITLE_TEXT_COLOR); passwordTextArea.setText(message); passwordTextArea.setBackground(Color.WHITE); passwordTextArea.setDisabledTextColor(Color.RED); finishButton.setEnabled(false); setModal(true); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { cancelButtonActionPerformed(null); } }); 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); } setVisible(true); }
From source file:geneticalgorithm.gui.view.VGraphic.java
public VGraphic(String title, String xLabel, String yLabel) { setSize(800, 600);/*from ww w.ja va2 s.c o m*/ setLocationRelativeTo(this); setTitle(title); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { dispose(); } }); setLayout(new BorderLayout()); average = new XYSeries("Average"); offline = new XYSeries("Offline"); online = new XYSeries("Online"); dataset = new XYSeriesCollection(); dataset.addSeries(average); dataset.addSeries(offline); dataset.addSeries(online); chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false); add(new ChartPanel(chart), BorderLayout.CENTER); JPanel south = new JPanel(new MigLayout()); lblAverage = new JLabel(""); lblAverage.setHorizontalTextPosition(SwingConstants.LEFT); lblAverage.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblAverageTitle = new JLabel("Average: "); lblAverageTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblAverageTitle); south.add(lblAverage, "wrap"); lblOffline = new JLabel(""); lblOffline.setHorizontalTextPosition(SwingConstants.LEFT); lblOffline.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblOfflineTitle = new JLabel("Offline: "); lblOfflineTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblOfflineTitle); south.add(lblOffline, "wrap"); lblOnline = new JLabel(""); lblOnline.setHorizontalTextPosition(SwingConstants.LEFT); lblOnline.setFont(new Font("ARIAL", Font.BOLD, 26)); JLabel lblOnlineTitle = new JLabel("Online: "); lblOnlineTitle.setFont(new Font("ARIAL", Font.BOLD, 26)); south.add(lblOnlineTitle); south.add(lblOnline, "wrap"); add(south, BorderLayout.SOUTH); }
From source file:Main.java
/** * Initialises the {@link JDialog} for the {@link JComponent}. * /*from ww w . ja v a2 s . co m*/ * @param dialog * @param component * @param parentComponent */ private static void initDialog(final JDialog dialog, final JComponent component, final Component parentComponent) { dialog.setResizable(true); dialog.setComponentOrientation(component.getComponentOrientation()); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(component, BorderLayout.CENTER); final int buttonWidth = 75; final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4)); buttonPanel.add(Box.createHorizontalGlue()); @SuppressWarnings("serial") final Action closeAction = new AbstractAction("Close") { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; final JButton button = new JButton(closeAction); fixWidth(button, buttonWidth); buttonPanel.add(button); contentPane.add(buttonPanel, BorderLayout.SOUTH); if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.setUndecorated(true); component.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); } } dialog.pack(); dialog.setLocationRelativeTo(parentComponent); WindowAdapter adapter = new WindowAdapter() { // private boolean gotFocus = false; public void windowClosing(WindowEvent we) { fireAction(we.getSource(), closeAction, "close"); } }; dialog.addWindowListener(adapter); dialog.addWindowFocusListener(adapter); }
From source file:BeanContainer.java
public BeanContainer() { super("Simple Bean Container"); getContentPane().setLayout(new FlowLayout()); //from www . j ava 2 s. co m setSize(300, 300); JPopupMenu.setDefaultLightWeightPopupEnabled(false); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:LayeredPaneDemo2.java
public LayeredPaneDemo2() { super("Custom MDI: Part III"); setSize(570, 400);//from www. j a v a 2s .com getContentPane().setBackground(new Color(244, 232, 152)); getLayeredPane().setOpaque(true); // VERY IMPORTANT!! ImageIcon ii = new ImageIcon("earth.jpg"); InnerFrame[] frames = new InnerFrame[5]; for (int i = 0; i < 5; i++) { frames[i] = new InnerFrame("InnerFrame " + i); frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200); frames[i].getContentPane().add(new JScrollPane(new JLabel(ii))); getLayeredPane().add(frames[i]); } WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); ImageIcon image = new ImageIcon("spiral.gif"); setIconImage(image.getImage()); addWindowListener(l); setVisible(true); }
From source file:CascadeDemo.java
public CascadeDemo() { super("CascadeDemo"); EARTH = new ImageIcon("earth.jpg"); m_count = m_tencount = 0;//from ww w . j av a2 s .c o m m_desktop = new JDesktopPane(); m_desktop.putClientProperty("JDesktopPane.dragMode", "outline"); m_newFrame = new JButton("New Frame"); m_newFrame.addActionListener(this); m_infos = UIManager.getInstalledLookAndFeels(); String[] LAFNames = new String[m_infos.length]; for (int i = 0; i < m_infos.length; i++) { LAFNames[i] = m_infos[i].getName(); } m_UIBox = new JComboBox(LAFNames); m_UIBox.addActionListener(this); JPanel topPanel = new JPanel(true); topPanel.add(m_newFrame); topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT)); topPanel.add(m_UIBox); getContentPane().setLayout(new BorderLayout()); getContentPane().add("North", topPanel); getContentPane().add("Center", m_desktop); setSize(570, 400); Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); }
From source file:GUIManagerQuery.java
/*************************************************************************** * Construct the GUIManagerQuery object, constructing the various components * and laying them out on the screen./* w w w . j a v a2 s . c o m*/ **************************************************************************/ public GUIManagerQuery() { super("GUIManagerQuery"); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); versionLabel = new Label("JMF v" + Manager.getVersion()); add(versionLabel, "North"); Panel lower = new Panel(); lower.add(new Label("Content/Protocol")); contentsField = new TextField(32); lower.add(contentsField); add(lower, "South"); results = new TextArea(20, 80); results.setEditable(false); add(results, "Center"); Panel controls = new Panel(); controls.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); hintsButton = new Button("Hints"); gbc.gridx = 0; gbc.gridy = 0; controls.add(hintsButton, gbc); hintsButton.addActionListener(this); playersButton = new Button("Players"); gbc.gridy = 1; controls.add(playersButton, gbc); playersButton.addActionListener(this); processorsButton = new Button("Processors"); gbc.gridy = 2; controls.add(processorsButton, gbc); processorsButton.addActionListener(this); sourcesButton = new Button("DataSources"); gbc.gridy = 3; controls.add(sourcesButton, gbc); sourcesButton.addActionListener(this); add(controls, "East"); }
From source file:LayeredPaneDemo.java
public LayeredPaneDemo() { super(""); setSize(570, 400);/*from w w w . j av a2 s . c o m*/ getContentPane().setBackground(new Color(244, 232, 152)); getLayeredPane().setOpaque(true); InnerFrame[] frames = new InnerFrame[5]; for (int i = 0; i < 5; i++) { frames[i] = new InnerFrame("InnerFrame " + i); frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200); getLayeredPane().add(frames[i]); } WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); setVisible(true); }
From source file:ch.unibas.fittingwizard.application.Visualization.java
/** * Visualising with JMol a given SMILES string * * @param smiles//from w ww .j av a2 s . c o m */ public void showSMILES(String smiles) { if (jmolWindow == null) { logger.info("Creating Jmol window."); jmolWindow = new JFrame("Visualization of " + smiles); jmolWindow.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { logger.info("Jmol window closing."); jmolWindow = null; jmolViewer = null; currentOpenFile = null; } }); jmolWindow.setSize(600, 600); Container contentPane = jmolWindow.getContentPane(); JmolPanel jmolPanel = new JmolPanel(); // main panel -- Jmol panel on top JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(jmolPanel); contentPane.add(panel); jmolViewer = jmolPanel.viewer; alignWindowPositionToWizard(); jmolWindow.setVisible(true); } else { logger.debug("Bringing existing Jmol window to front."); } jmolViewer.scriptWait("load $" + smiles); jmolWindow.toFront(); }
From source file:ColorComposite.java
public ColorComposite() { super();/* w ww . ja va 2s.com*/ Container container = getContentPane(); canvas = new MyCanvas(); container.add(canvas); JPanel panel = new JPanel(); JLabel label = new JLabel("Color-Composite: "); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 65); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider tempSlider = (JSlider) e.getSource(); alphaValue = (float) (tempSlider.getValue() / 100.0); textField.setText(Float.toString(alphaValue)); canvas.repaint(); } }); textField = new JTextField("0.65", 4); panel.add(label); panel.add(slider); panel.add(textField); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(450, 450); setVisible(true); }