use of jmri.jmrit.throttle.StopAllButton in project JMRI by JMRI.
the class UserInterface method createWindow.
protected void createWindow() {
panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints con = new GridBagConstraints();
getContentPane().add(panel);
con.fill = GridBagConstraints.NONE;
con.weightx = 0.5;
con.weighty = 0;
JLabel label = new JLabel(MessageFormat.format(rb.getString("LabelAdvertising"), new Object[] { DeviceServer.getWiTVersion() }));
con.gridx = 0;
con.gridy = 0;
con.gridwidth = 2;
panel.add(label, con);
con.gridx = 0;
con.gridy = 1;
con.gridwidth = 2;
panel.add(portLabel, con);
con.gridy = 2;
panel.add(manualPortLabel, con);
numConnected = new JLabel(rb.getString("LabelClients") + " " + deviceList.size());
con.weightx = 0;
con.gridx = 2;
con.gridy = 2;
con.ipadx = 5;
con.gridwidth = 1;
panel.add(numConnected, con);
JPanel rgsPanel = new JPanel();
rgsPanel.add(new JLabel(rb.getString("RosterGroupLabel")));
rgsPanel.add(rosterGroupSelector);
rgsPanel.setToolTipText(rb.getString("RosterGroupToolTip"));
JToolBar withrottleToolBar = new JToolBar();
withrottleToolBar.setFloatable(false);
withrottleToolBar.add(new StopAllButton());
withrottleToolBar.add(new LargePowerManagerButton());
withrottleToolBar.add(rgsPanel);
con.weightx = 0.5;
con.ipadx = 0;
con.gridx = 1;
con.gridy = 3;
con.gridwidth = 2;
panel.add(withrottleToolBar, con);
/*
JLabel vLabel = new JLabel("v"+DeviceServer.getWiTVersion());
con.weightx = 0;
con.gridx = 2;
con.gridy = 3;
panel.add(vLabel, con);
*/
JLabel icon;
java.net.URL imageURL = FileUtil.findURL("resources/IconForWiThrottle.gif");
if (imageURL != null) {
ImageIcon image = new ImageIcon(imageURL);
icon = new JLabel(image);
con.weightx = 0.5;
con.gridx = 2;
con.gridy = 0;
con.ipady = 5;
con.gridheight = 2;
panel.add(icon, con);
}
// Add a list of connected devices and the address they are set to.
withrottlesListModel = new WiThrottlesListModel(deviceList);
withrottlesList = new JTable(withrottlesListModel);
withrottlesList.setPreferredScrollableViewportSize(new Dimension(300, 80));
withrottlesList.setRowHeight(20);
scrollTable = new JScrollPane(withrottlesList);
con.gridx = 0;
con.gridy = 4;
con.weighty = 1.0;
con.ipadx = 10;
con.ipady = 10;
con.gridheight = 3;
con.gridwidth = GridBagConstraints.REMAINDER;
con.fill = GridBagConstraints.BOTH;
panel.add(scrollTable, con);
// Create the menu to use with WiThrottle window. Has to be before pack() for Windows.
buildMenu();
// Set window size & location
this.setTitle("WiThrottle");
this.pack();
this.setResizable(true);
Rectangle screenRect = new Rectangle(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
// Centers on top edge of screen
this.setLocation((screenRect.width / 2) - (this.getWidth() / 2), 0);
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
setVisible(true);
setMinimumSize(getSize());
rosterGroupSelector.addActionListener(new ActionListener() {
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
userPreferences.addComboBoxLastSelection(rosterGroupSelectorPreferencesName, (String) ((JComboBox<String>) e.getSource()).getSelectedItem());
// Send new selected roster group to all devices
for (DeviceServer device : deviceList) {
device.sendPacketToDevice(device.sendRoster());
}
}
});
}
Aggregations