Search in sources :

Example 1 with LargePowerManagerButton

use of jmri.jmrit.throttle.LargePowerManagerButton 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());
            }
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) LargePowerManagerButton(jmri.jmrit.throttle.LargePowerManagerButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) Rectangle(java.awt.Rectangle) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) StopAllButton(jmri.jmrit.throttle.StopAllButton)

Example 2 with LargePowerManagerButton

use of jmri.jmrit.throttle.LargePowerManagerButton in project JMRI by JMRI.

the class RosterFrame method additionsToToolBar.

void additionsToToolBar() {
    //This value may return null if the DP3 window has been called from a the traditional JMRI menu frame
    if (Apps3.buttonSpace() != null) {
        getToolBar().add(Apps3.buttonSpace());
    }
    getToolBar().add(new LargePowerManagerButton(true));
    getToolBar().add(modePanel);
}
Also used : LargePowerManagerButton(jmri.jmrit.throttle.LargePowerManagerButton)

Aggregations

LargePowerManagerButton (jmri.jmrit.throttle.LargePowerManagerButton)2 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Rectangle (java.awt.Rectangle)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ImageIcon (javax.swing.ImageIcon)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 JToolBar (javax.swing.JToolBar)1 StopAllButton (jmri.jmrit.throttle.StopAllButton)1