Search in sources :

Example 61 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class FamilyItemPanel method addIconsToPanel.

protected void addIconsToPanel(HashMap<String, NamedIcon> iconMap) {
    if (iconMap == null) {
        log.warn("iconMap is null for type " + _itemType + " family " + _family);
        return;
    }
    GridBagLayout gridbag = new GridBagLayout();
    _iconPanel.setLayout(gridbag);
    int numCol = 4;
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.gridx = -1;
    c.gridy = 0;
    int cnt = iconMap.size();
    Iterator<Entry<String, NamedIcon>> it = iconMap.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, NamedIcon> entry = it.next();
        // make copy for possible reduction
        NamedIcon icon = new NamedIcon(entry.getValue());
        icon.reduceTo(100, 100, 0.2);
        JPanel panel = new JPanel(new FlowLayout());
        // I18N use existing NamedBeanBundle keys
        String borderName = getIconBorderName(entry.getKey());
        panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), borderName));
        JLabel image = new JLabel(icon);
        if (icon.getIconWidth() < 1 || icon.getIconHeight() < 1) {
            image.setText(Bundle.getMessage("invisibleIcon"));
            image.setForeground(Color.lightGray);
        }
        image.setToolTipText(icon.getName());
        panel.add(image);
        int width = getFontMetrics(getFont()).stringWidth(borderName);
        width = Math.max(100, Math.max(width, icon.getIconWidth()) + 10);
        panel.setPreferredSize(new java.awt.Dimension(width, panel.getPreferredSize().height));
        c.gridx += 1;
        if (c.gridx >= numCol) {
            //start next row
            c.gridy++;
            c.gridx = 0;
            if (cnt < numCol - 1) {
                // last row
                JPanel p = new JPanel(new FlowLayout());
                p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
                p.add(Box.createHorizontalStrut(100));
                gridbag.setConstraints(p, c);
                //if (log.isDebugEnabled()) log.debug("addIconsToPanel: gridx= "+c.gridx+" gridy= "+c.gridy);
                _iconPanel.add(p);
                c.gridx = 1;
            }
        }
        cnt--;
        gridbag.setConstraints(panel, c);
        _iconPanel.add(panel);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) NamedIcon(jmri.jmrit.catalog.NamedIcon) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Entry(java.util.Map.Entry)

Example 62 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class DetectionPanel method openPickList.

void openPickList() {
    _pickFrame = new JFrame();
    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    JPanel blurb = new JPanel();
    blurb.setLayout(new BoxLayout(blurb, BoxLayout.Y_AXIS));
    blurb.add(Box.createVerticalStrut(ItemPalette.STRUT_SIZE));
    blurb.add(new JLabel(Bundle.getMessage("DragOccupancyName", Bundle.getMessage("DetectionSensor"))));
    blurb.add(new JLabel(Bundle.getMessage("DragErrorName", Bundle.getMessage("ErrorSensor"))));
    blurb.add(Box.createVerticalStrut(ItemPalette.STRUT_SIZE));
    JPanel panel = new JPanel();
    panel.add(blurb);
    content.add(panel);
    PickListModel[] models = { PickListModel.oBlockPickModelInstance(), PickListModel.sensorPickModelInstance() };
    content.add(new PickPanel(models));
    _pickFrame.setContentPane(content);
    _pickFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            closePickList();
        }
    });
    _pickFrame.setLocationRelativeTo(this);
    _pickFrame.toFront();
    _pickFrame.setVisible(true);
    _pickFrame.pack();
    _openPicklistButton.setText(Bundle.getMessage("ClosePicklist"));
}
Also used : JPanel(javax.swing.JPanel) PickPanel(jmri.jmrit.picker.PickPanel) PickListModel(jmri.jmrit.picker.PickListModel) JFrame(javax.swing.JFrame) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel)

Example 63 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class MemoryItemPanel method initIconFamiliesPanel.

@Override
protected void initIconFamiliesPanel() {
    _iconFamilyPanel = new JPanel();
    _iconFamilyPanel.setLayout(new BoxLayout(_iconFamilyPanel, BoxLayout.Y_AXIS));
    if (!_update) {
        _iconFamilyPanel.add(instructions());
    }
    makeDndIconPanel(null, null);
    _iconFamilyPanel.add(_dragIconPanel);
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout)

Example 64 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class MultiSensorItemPanel method makeMultiSensorPanel.

private void makeMultiSensorPanel() {
    _multiSensorPanel = new JPanel();
    _multiSensorPanel.setLayout(new BoxLayout(_multiSensorPanel, BoxLayout.Y_AXIS));
    JPanel panel2 = new JPanel();
    ButtonGroup group2 = new ButtonGroup();
    JRadioButton button = new JRadioButton(Bundle.getMessage("LeftRight"));
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _upDown = false;
        }
    });
    group2.add(button);
    panel2.add(button);
    button.setSelected(true);
    button = new JRadioButton(Bundle.getMessage("UpDown"));
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _upDown = true;
        }
    });
    group2.add(button);
    panel2.add(button);
    _multiSensorPanel.add(panel2);
    _multiSensorPanel.repaint();
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout)

Example 65 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class ReporterItemPanel method initIconFamiliesPanel.

@Override
protected void initIconFamiliesPanel() {
    _iconFamilyPanel = new JPanel();
    _iconFamilyPanel.setLayout(new BoxLayout(_iconFamilyPanel, BoxLayout.Y_AXIS));
    if (!_update) {
        _iconFamilyPanel.add(instructions());
    }
    _iconPanel = new JPanel(new FlowLayout());
    _iconFamilyPanel.add(_iconPanel);
    makeDndIconPanel(null, null);
    _iconFamilyPanel.add(_dragIconPanel);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) BoxLayout(javax.swing.BoxLayout)

Aggregations

BoxLayout (javax.swing.BoxLayout)593 JPanel (javax.swing.JPanel)510 JLabel (javax.swing.JLabel)301 Dimension (java.awt.Dimension)189 ActionEvent (java.awt.event.ActionEvent)179 JButton (javax.swing.JButton)173 ActionListener (java.awt.event.ActionListener)155 JScrollPane (javax.swing.JScrollPane)140 FlowLayout (java.awt.FlowLayout)130 JCheckBox (javax.swing.JCheckBox)74 BorderLayout (java.awt.BorderLayout)73 GridBagLayout (java.awt.GridBagLayout)66 ButtonGroup (javax.swing.ButtonGroup)58 JTable (javax.swing.JTable)53 JTextField (javax.swing.JTextField)53 Container (java.awt.Container)51 JmriJFrame (jmri.util.JmriJFrame)45 JComboBox (javax.swing.JComboBox)44 JSeparator (javax.swing.JSeparator)44 Box (javax.swing.Box)41