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