Search in sources :

Example 76 with WindowEvent

use of java.awt.event.WindowEvent in project JMRI by JMRI.

the class AddNodeFrame method addButtonActionPerformed.

/**
     * Method to handle add button
     */
@Override
public void addButtonActionPerformed() {
    if (nodeAddr64Field.getText().equals("") && nodeAddrField.getText().equals("")) {
        // no address, just return.
        return;
    }
    // Check that a node with this address does not exist
    // if the 64 bit address field is blank, use the "Unknown" address".
    XBee64BitAddress guid;
    if (!(nodeAddr64Field.getText().equals(""))) {
        byte[] GUID = jmri.util.StringUtil.bytesFromHexString(nodeAddr64Field.getText());
        guid = new XBee64BitAddress(GUID);
    } else {
        guid = XBee64BitAddress.UNKNOWN_ADDRESS;
    }
    // if the 16 bit address field is blank, use the "Unknown" address".
    XBee16BitAddress address;
    if (!(nodeAddrField.getText().equals(""))) {
        byte[] addr = jmri.util.StringUtil.bytesFromHexString(nodeAddrField.getText());
        address = new XBee16BitAddress(addr);
    } else {
        address = XBee16BitAddress.UNKNOWN_ADDRESS;
    }
    String Identifier = nodeIdentifierField.getText();
    // create the RemoteXBeeDevice for the node.
    RemoteXBeeDevice remoteDevice = new RemoteXBeeDevice(xtc.getXBee(), guid, address, Identifier);
    // get a XBeeNode corresponding to this node address if one exists
    curNode = (XBeeNode) xtc.getNodeFromXBeeDevice(remoteDevice);
    if (curNode != null) {
        javax.swing.JOptionPane.showMessageDialog(this, Bundle.getMessage("Error1", remoteDevice), Bundle.getMessage("AddNodeErrorTitle"), JOptionPane.ERROR_MESSAGE);
        return;
    }
    try {
        // and then add it to the network
        xtc.getXBee().getNetwork().addRemoteDevice(remoteDevice);
        // create node (they register themselves)
        XBeeNode node = new XBeeNode(remoteDevice);
        xtc.registerNode(node);
        parent.nodeListChanged();
    } catch (TimeoutException toe) {
        log.error("Timeout adding node {}.", remoteDevice);
        javax.swing.JOptionPane.showMessageDialog(this, Bundle.getMessage("Error3"), Bundle.getMessage("AddNodeErrorTitle"), JOptionPane.ERROR_MESSAGE);
        log.error("Error creating XBee Node, constructor returned null");
        return;
    } catch (XBeeException xbe) {
        log.error("Exception adding node {}.", remoteDevice);
        javax.swing.JOptionPane.showMessageDialog(this, Bundle.getMessage("Error3"), Bundle.getMessage("AddNodeErrorTitle"), JOptionPane.ERROR_MESSAGE);
        log.error("Error creating XBee Node, constructor returned null");
        return;
    }
    this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
Also used : XBee64BitAddress(com.digi.xbee.api.models.XBee64BitAddress) RemoteXBeeDevice(com.digi.xbee.api.RemoteXBeeDevice) WindowEvent(java.awt.event.WindowEvent) XBee16BitAddress(com.digi.xbee.api.models.XBee16BitAddress) XBeeException(com.digi.xbee.api.exceptions.XBeeException) XBeeNode(jmri.jmrix.ieee802154.xbee.XBeeNode) TimeoutException(com.digi.xbee.api.exceptions.TimeoutException)

Example 77 with WindowEvent

use of java.awt.event.WindowEvent in project JMRI by JMRI.

the class AddNodeFrame method addButtonActionPerformed.

/**
     * Method to handle add button
     */
public void addButtonActionPerformed() {
    // Check that a node with this address does not exist
    String nodeAddress = readNodeAddress();
    if (nodeAddress.equals("")) {
        return;
    }
    // get a IEEE802154 Node corresponding to this node address if one exists
    curNode = (IEEE802154Node) itc.getNodeFromAddress(nodeAddress);
    if (curNode != null) {
        javax.swing.JOptionPane.showMessageDialog(this, Bundle.getMessage("Error1", nodeAddress), Bundle.getMessage("AddNodeErrorTitle"), JOptionPane.ERROR_MESSAGE);
        log.error("Error creating IEEE802154 Node, Node exists.");
        return;
    }
    // get node information from window
    // all ready, create the new node
    curNode = itc.newNode();
    if (curNode == null) {
        javax.swing.JOptionPane.showMessageDialog(this, Bundle.getMessage("Error3"), Bundle.getMessage("AddNodeErrorTitle"), JOptionPane.ERROR_MESSAGE);
        log.error("Error creating IEEE802154 Node, constructor returned null");
        return;
    }
    this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
Also used : WindowEvent(java.awt.event.WindowEvent)

Example 78 with WindowEvent

use of java.awt.event.WindowEvent in project JMRI by JMRI.

the class EditNodeFrame method editButtonActionPerformed.

/**
     * Method to handle edit button
     */
public void editButtonActionPerformed() {
    // get node information from window
    // all ready, update the node
    curNode.setUserAddress(jmri.util.StringUtil.bytesFromHexString(nodeAddrField.getText()));
    curNode.setGlobalAddress(jmri.util.StringUtil.bytesFromHexString(nodeAddr64Field.getText()));
    this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
Also used : WindowEvent(java.awt.event.WindowEvent)

Example 79 with WindowEvent

use of java.awt.event.WindowEvent in project cloudstack by apache.

the class VncClient method createVncClientMainWindow.

private Frame createVncClientMainWindow(BufferedImageCanvas canvas, String title) {
    // Create AWT windows
    final Frame frame = new Frame(title + " - VNCle");
    // Use scrolling pane to support screens, which are larger than ours
    ScrollPane scroller = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
    scroller.add(canvas);
    scroller.setSize(screen.getFramebufferWidth(), screen.getFramebufferHeight());
    frame.add(scroller);
    frame.pack();
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            frame.setVisible(false);
            shutdown();
        }
    });
    return frame;
}
Also used : Frame(java.awt.Frame) ScrollPane(java.awt.ScrollPane) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 80 with WindowEvent

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

the class VSyncedBufferStrategyTest method createAndShowBSFrame.

private static Frame createAndShowBSFrame() {
    final Frame f = new Frame("Not V-Synced");
    int myNum;
    synchronized (VSyncedBufferStrategyTest.class) {
        myNum = frameNum++;
    }
    final VSyncedBufferStrategyTest component = new VSyncedBufferStrategyTest(false);
    f.setIgnoreRepaint(true);
    f.add("Center", component);
    Panel p = new Panel();
    Button b = new Button("Request VSync");
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            f.setTitle("Possibly V-Synced");
            component.setRequestVSync(true);
        }
    });
    p.add(b);
    b = new Button("Relinquish VSync");
    b.addActionListener(new ActionListener() {

        int inc = 1;

        public void actionPerformed(ActionEvent e) {
            f.setTitle("Not V-Synced");
            component.setRequestVSync(false);
            f.setSize(f.getWidth() + inc, f.getHeight());
            inc = -inc;
        }
    });
    p.add(b);
    f.add("South", p);
    f.pack();
    f.setLocation(10, myNum * f.getHeight());
    f.setVisible(true);
    f.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            component.done = true;
            f.dispose();
        }

        @Override
        public void windowClosed(WindowEvent e) {
            component.done = true;
        }
    });
    return f;
}
Also used : Panel(java.awt.Panel) JPanel(javax.swing.JPanel) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) ActionListener(java.awt.event.ActionListener) Button(java.awt.Button) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Aggregations

WindowEvent (java.awt.event.WindowEvent)201 WindowAdapter (java.awt.event.WindowAdapter)140 JPanel (javax.swing.JPanel)44 JButton (javax.swing.JButton)40 JFrame (javax.swing.JFrame)40 BorderLayout (java.awt.BorderLayout)36 ActionEvent (java.awt.event.ActionEvent)34 Dimension (java.awt.Dimension)32 JLabel (javax.swing.JLabel)30 JScrollPane (javax.swing.JScrollPane)26 ActionListener (java.awt.event.ActionListener)25 GridBagConstraints (java.awt.GridBagConstraints)19 GridBagLayout (java.awt.GridBagLayout)19 FlowLayout (java.awt.FlowLayout)18 Frame (java.awt.Frame)15 Insets (java.awt.Insets)15 JDialog (javax.swing.JDialog)13 JTextArea (javax.swing.JTextArea)13 Container (java.awt.Container)12 WindowListener (java.awt.event.WindowListener)10