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));
}
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));
}
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));
}
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;
}
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;
}
Aggregations