hostButtons.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(),
"Hosts"));
// now fill in one button for each known host and select the live ones
for (Iterator iter = Host.allHosts(); iter.hasNext(); ) {
Host host = (Host) iter.next();
HostButton hostButton = new HostButton(host);
buttonSet.add(hostButton);
hostButtons.add(hostButton);
options.hosts.add(host);
if (hostButton.isEnabled()) {
options.selectedHosts.add(host);
options.liveHosts.add(host);
}
}
hostButtons.setToolTipText("Select which hosts you want to use.");
hostPanel.add(hostButtons, c);
// button panel
btnPanel.setLayout(new GridLayout(1, 2, 10, 10));
// btnPanel.setMaximumSize(new Dimension(60, 100));
// btnPanel.setPreferredSize(new Dimension(60, 100));
addButton = new JButton("Add");
background = addButton.getBackground();
foreground = addButton.getForeground();
addButton.setBorder(BorderFactory.createRaisedBevelBorder());
addButton.addMouseListener(this);
addButton.setToolTipText("add Host to list");
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
hostField.setText("");
String hostName = (String) JOptionPane.showInputDialog(null,
"Enter host name",
"Add Host",
JOptionPane.QUESTION_MESSAGE,
null,
null,
"");
if (hostName == null)
return; // didn't mean it
Host host = null;
try {
host = new Host(hostName); // bogus?
} catch (UnknownHostException x) {
JOptionPane.showMessageDialog(null,
"Cannot find host named " + hostName,
"Error",
JOptionPane.ERROR_MESSAGE);