Search in sources :

Example 96 with WindowAdapter

use of java.awt.event.WindowAdapter in project ACS by ACS-Community.

the class CDBAddNodeDlg method initComponents.

private void initComponents() {
    GridBagConstraints gridBagConstraints;
    curlLabel = new JLabel();
    curlCtrl = new JTextField();
    xmlDataCtrl = new JTextArea();
    getContentPane().setLayout(new GridBagLayout());
    setTitle("Add new node");
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent evt) {
            closeDialog(evt);
        }
    });
    curlLabel.setText("Curl:");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.insets = new Insets(11, 11, 11, 11);
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    getContentPane().add(curlLabel, gridBagConstraints);
    curlCtrl.setBorder(new javax.swing.border.EtchedBorder());
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(11, 11, 11, 11);
    gridBagConstraints.weightx = 1.0;
    getContentPane().add(curlCtrl, gridBagConstraints);
    xmlDataCtrl.setBorder(new EtchedBorder());
    xmlDataCtrl.setPreferredSize(new Dimension(400, 300));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagConstraints.gridheight = GridBagConstraints.RELATIVE;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.insets = new Insets(11, 11, 11, 11);
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    getContentPane().add(xmlDataCtrl, gridBagConstraints);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    okBtn = new JButton();
    cancelBtn = new JButton();
    okBtn.addActionListener(this);
    okBtn.setText("OK");
    buttonsPanel.add(okBtn);
    cancelBtn.addActionListener(this);
    cancelBtn.setText("Cancel");
    buttonsPanel.add(cancelBtn);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    getContentPane().add(buttonsPanel, gridBagConstraints);
    setBounds(70, 70, 70, 70);
    pack();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) GridBagConstraints(java.awt.GridBagConstraints) EtchedBorder(javax.swing.border.EtchedBorder) WindowEvent(java.awt.event.WindowEvent) EtchedBorder(javax.swing.border.EtchedBorder)

Example 97 with WindowAdapter

use of java.awt.event.WindowAdapter in project ACS by ACS-Community.

the class CDBBrowser method main.

public static void main(String[] args) {
    CDBBrowser app = new CDBBrowser();
    // test for IOR in cmd line
    for (int i = 0; i < args.length; i++) {
        if (args[i].equals("-d")) {
            if (i < args.length - 1) {
                app.setIOR(args[++i]);
            }
        }
        if (args[i].equals("-h") || args[i].equals("-help")) {
            System.out.println("Usage: cmd [-d ior -h|-help]");
            return;
        }
    }
    Frame frame = new Frame("CDB Browser");
    frame.add(app);
    frame.setSize(800, 600);
    frame.setLocationRelativeTo(null);
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    app.init();
    app.start();
    frame.setVisible(true);
}
Also used : Frame(java.awt.Frame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 98 with WindowAdapter

use of java.awt.event.WindowAdapter in project ACS by ACS-Community.

the class Launcher method createFrame.

protected JFrame createFrame(String title) {
    final JFrame ret = new JFrame(title);
    ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    ret.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            int answer = JOptionPane.showConfirmDialog(ret, "Really close Acs VmTools?", "Close Window", JOptionPane.YES_NO_OPTION);
            if (answer == JOptionPane.YES_OPTION) {
                ret.setVisible(false);
                ret.dispose();
            }
        }
    });
    return ret;
}
Also used : JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 99 with WindowAdapter

use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.

the class WindowsMenuBarUI method installWindowListener.

private void installWindowListener() {
    if (windowListener == null) {
        Component component = menuBar.getTopLevelAncestor();
        if (component instanceof Window) {
            window = (Window) component;
            windowListener = new WindowAdapter() {

                @Override
                public void windowActivated(WindowEvent e) {
                    menuBar.repaint();
                }

                @Override
                public void windowDeactivated(WindowEvent e) {
                    menuBar.repaint();
                }
            };
            ((Window) component).addWindowListener(windowListener);
        }
    }
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 100 with WindowAdapter

use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.

the class MultiResolutionTrayIconTest method createUI.

public static void createUI() throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            mainFrame = new JFrame("TrayIcon Test");
            boolean trayIsSupported = SystemTray.isSupported();
            tray = SystemTray.getSystemTray();
            Dimension d = tray.getTrayIconSize();
            icon = new TrayIcon(createIcon(d.width, d.height));
            icon.setImageAutoSize(true);
            layout = new GridBagLayout();
            mainControlPanel = new JPanel(layout);
            resultButtonPanel = new JPanel(layout);
            GridBagConstraints gbc = new GridBagConstraints();
            String instructions = "<html>INSTRUCTIONS:<br>" + "Press start button to add icon to system tray.<br><br>" + "If Icon color is green test" + " passes else failed.<br><br></html>";
            instructionText = new JLabel();
            instructionText.setText(instructions);
            gbc.gridx = 0;
            gbc.gridy = 0;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            mainControlPanel.add(instructionText, gbc);
            startButton = new JButton("Start");
            startButton.setActionCommand("Start");
            if (trayIsSupported) {
                startButton.addActionListener((ActionEvent e) -> {
                    doTest();
                });
            } else {
                startButton.setEnabled(false);
                System.out.println("system tray is not supported");
                latch.countDown();
            }
            gbc.gridx = 0;
            gbc.gridy = 0;
            resultButtonPanel.add(startButton, gbc);
            passButton = new JButton("Pass");
            passButton.setActionCommand("Pass");
            passButton.addActionListener((ActionEvent e) -> {
                latch.countDown();
                removeIcon();
                mainFrame.dispose();
            });
            failButton = new JButton("Fail");
            failButton.setActionCommand("Fail");
            failButton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    removeIcon();
                    latch.countDown();
                    mainFrame.dispose();
                    throw new RuntimeException("Test Failed");
                }
            });
            gbc.gridx = 1;
            gbc.gridy = 0;
            resultButtonPanel.add(passButton, gbc);
            gbc.gridx = 2;
            gbc.gridy = 0;
            resultButtonPanel.add(failButton, gbc);
            gbc.gridx = 0;
            gbc.gridy = 1;
            mainControlPanel.add(resultButtonPanel, gbc);
            mainFrame.add(mainControlPanel);
            mainFrame.setSize(400, 200);
            mainFrame.setLocationRelativeTo(null);
            mainFrame.setVisible(true);
            mainFrame.addWindowListener(new WindowAdapter() {

                @Override
                public void windowClosing(WindowEvent e) {
                    removeIcon();
                    latch.countDown();
                    mainFrame.dispose();
                }
            });
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) ActionListener(java.awt.event.ActionListener) JFrame(javax.swing.JFrame) TrayIcon(java.awt.TrayIcon) WindowEvent(java.awt.event.WindowEvent)

Aggregations

WindowAdapter (java.awt.event.WindowAdapter)129 WindowEvent (java.awt.event.WindowEvent)128 JPanel (javax.swing.JPanel)37 JButton (javax.swing.JButton)34 BorderLayout (java.awt.BorderLayout)31 JFrame (javax.swing.JFrame)30 Dimension (java.awt.Dimension)29 JLabel (javax.swing.JLabel)26 JScrollPane (javax.swing.JScrollPane)24 ActionEvent (java.awt.event.ActionEvent)21 ActionListener (java.awt.event.ActionListener)19 GridBagConstraints (java.awt.GridBagConstraints)18 GridBagLayout (java.awt.GridBagLayout)18 FlowLayout (java.awt.FlowLayout)17 Insets (java.awt.Insets)13 JTextArea (javax.swing.JTextArea)12 Container (java.awt.Container)11 Frame (java.awt.Frame)10 JDialog (javax.swing.JDialog)9 IOException (java.io.IOException)8