use of javax.swing.border.TitledBorder in project JMRI by JMRI.
the class AddSignalMastPanel method dccUnLitPanel.
void dccUnLitPanel() {
dccUnLitPanel.setLayout(new BoxLayout(dccUnLitPanel, BoxLayout.Y_AXIS));
JPanel dccDetails = new JPanel();
dccDetails.add(new JLabel(Bundle.getMessage("DCCMastSetAspectId") + ":"));
dccDetails.add(unLitAspectField);
unLitAspectField.setText("31");
dccUnLitPanel.add(dccDetails);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
border.setTitle(Bundle.getMessage("DCCUnlitAspectNumber"));
dccUnLitPanel.setBorder(border);
unLitAspectField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (unLitAspectField.getText().equals("")) {
return;
}
if (!validateAspectId(unLitAspectField.getText())) {
unLitAspectField.requestFocusInWindow();
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
}
use of javax.swing.border.TitledBorder in project JMRI by JMRI.
the class AddSignalMastPanel method matrixUnLitPanel.
/**
* JPanel to set outputs for an unlit (Dark) Matrix Signal Mast.
*/
void matrixUnLitPanel() {
if (bitNum < 1 || bitNum > MAXMATRIXBITS) {
// default to 4 col for (first) new mast
bitNum = 4;
}
/* if (unLitPanelBits == null) {
char[] unLitPanelBits = emptyBits;
// if needed, assign panel var to enable setting separate items by clicking a UnLitCheck check box
}*/
JPanel matrixUnLitDetails = new JPanel();
// stretch to full width
matrixUnLitDetails.setLayout(new jmri.util.javaworld.GridLayout2(1, 1));
//matrixUnLitDetails.setAlignmentX(matrixUnLitDetails.RIGHT_ALIGNMENT);
matrixUnLitDetails.add(UnLitCheck1);
matrixUnLitDetails.add(UnLitCheck2);
matrixUnLitDetails.add(UnLitCheck3);
matrixUnLitDetails.add(UnLitCheck4);
matrixUnLitDetails.add(UnLitCheck5);
matrixUnLitDetails.add(UnLitCheck6);
// repeat in order to set MAXMATRIXBITS > 6
//matrixUnLitDetails.add(unLitBitsField);
//unLitBitsField.setEnabled(false); // not editable, just for debugging
//unLitBitsField.setVisible(false); // set to true to check/debug unLitBits
matrixUnLitPanel.add(matrixUnLitDetails);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
border.setTitle(Bundle.getMessage("MatrixUnLitDetails"));
matrixUnLitPanel.setBorder(border);
matrixUnLitPanel.setToolTipText(Bundle.getMessage("MatrixUnlitTooltip"));
UnLitCheck1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setUnLitBit(1, UnLitCheck1.isSelected());
}
});
UnLitCheck2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setUnLitBit(2, UnLitCheck2.isSelected());
}
});
UnLitCheck3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setUnLitBit(3, UnLitCheck3.isSelected());
}
});
UnLitCheck4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setUnLitBit(4, UnLitCheck4.isSelected());
}
});
UnLitCheck5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setUnLitBit(5, UnLitCheck5.isSelected());
}
});
UnLitCheck6.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setUnLitBit(6, UnLitCheck6.isSelected());
}
});
// repeat in order to set MAXMATRIXBITS > 6
}
use of javax.swing.border.TitledBorder in project JMRI by JMRI.
the class LayoutTurnout method editLayoutTurnout.
/**
* Edit a Layout Turnout
*/
protected void editLayoutTurnout() {
if (editOpen) {
editLayoutTurnoutFrame.setVisible(true);
return;
}
// Initialize if needed
if (editLayoutTurnoutFrame == null) {
editLayoutTurnoutFrame = new JmriJFrame(rb.getString("EditTurnout"), false, true);
editLayoutTurnoutFrame.addHelpMenu("package.jmri.jmrit.display.EditLayoutTurnout", true);
editLayoutTurnoutFrame.setLocation(50, 30);
Container contentPane = editLayoutTurnoutFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
// setup turnout name
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel turnoutNameLabel = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanNameTurnout")));
panel1.add(turnoutNameLabel);
// add combobox to select turnout
firstTurnoutComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getTurnout(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
layoutEditor.setupComboBox(firstTurnoutComboBox, true, true);
panel1.add(firstTurnoutComboBox);
contentPane.add(panel1);
JPanel panel1a = new JPanel();
panel1a.setLayout(new BoxLayout(panel1a, BoxLayout.Y_AXIS));
secondTurnoutComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getSecondTurnout(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
layoutEditor.setupComboBox(secondTurnoutComboBox, true, false);
additionalTurnout.addActionListener((ActionEvent e) -> {
if (additionalTurnout.isSelected()) {
secondTurnoutLabel.setEnabled(true);
secondTurnoutComboBox.setEnabled(true);
} else {
secondTurnoutLabel.setEnabled(false);
secondTurnoutComboBox.setEnabled(false);
}
});
if ((type != DOUBLE_XOVER) && (type != RH_XOVER) && (type != LH_XOVER)) {
additionalTurnout.setText(rb.getString("ThrowTwoTurnouts"));
}
panel1a.add(additionalTurnout);
contentPane.add(panel1a);
secondTurnoutLabel = new JLabel(Bundle.getMessage("Supporting", Bundle.getMessage("BeanNameTurnout")));
secondTurnoutLabel.setEnabled(false);
secondTurnoutComboBox.setEnabled(false);
JPanel panel1b = new JPanel();
panel1b.add(secondTurnoutLabel);
panel1b.add(secondTurnoutComboBox);
contentPane.add(panel1b);
// add continuing state choice, if not crossover
if ((type != DOUBLE_XOVER) && (type != RH_XOVER) && (type != LH_XOVER)) {
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout());
stateBox.removeAllItems();
stateBox.addItem(InstanceManager.turnoutManagerInstance().getClosedText());
turnoutClosedIndex = 0;
stateBox.addItem(InstanceManager.turnoutManagerInstance().getThrownText());
turnoutThrownIndex = 1;
stateBox.setToolTipText(rb.getString("StateToolTip"));
panel3.add(new JLabel(rb.getString("ContinuingState")));
panel3.add(stateBox);
contentPane.add(panel3);
}
JPanel panel33 = new JPanel();
panel33.setLayout(new FlowLayout());
hiddenBox.setToolTipText(rb.getString("HiddenToolTip"));
panel33.add(hiddenBox);
contentPane.add(panel33);
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
border.setTitle(Bundle.getMessage("BeanNameBlock"));
// setup block name
JPanel panel2 = new JPanel();
panel2.setBorder(border);
panel2.setLayout(new FlowLayout());
panel2.add(blockNameComboBox);
layoutEditor.setupComboBox(blockNameComboBox, false, true);
blockNameComboBox.setToolTipText(rb.getString("EditBlockNameHint"));
panel2.add(turnoutEditBlock = new JButton(rb.getString("CreateEdit")));
turnoutEditBlock.addActionListener((ActionEvent e) -> {
turnoutEditBlockPressed(e);
});
contentPane.add(panel2);
if ((type == DOUBLE_XOVER) || (type == RH_XOVER) || (type == LH_XOVER)) {
JPanel panel21 = new JPanel();
panel21.setLayout(new FlowLayout());
TitledBorder borderblk2 = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
borderblk2.setTitle(Bundle.getMessage("BeanNameBlock") + " 2");
panel21.setBorder(borderblk2);
layoutEditor.setupComboBox(blockBNameComboBox, false, true);
blockBNameComboBox.setToolTipText(rb.getString("EditBlockBNameHint"));
panel21.add(blockBNameComboBox);
panel21.add(turnoutEditBlockB = new JButton(rb.getString("CreateEdit")));
turnoutEditBlockB.addActionListener((ActionEvent e) -> {
turnoutEditBlockBPressed(e);
});
turnoutEditBlockB.setToolTipText(Bundle.getMessage("EditBlockHint", "2"));
contentPane.add(panel21);
JPanel panel22 = new JPanel();
panel22.setLayout(new FlowLayout());
TitledBorder borderblk3 = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
borderblk3.setTitle(Bundle.getMessage("BeanNameBlock") + " 3");
panel22.setBorder(borderblk3);
layoutEditor.setupComboBox(blockCNameComboBox, false, true);
blockCNameComboBox.setToolTipText(rb.getString("EditBlockCNameHint"));
panel22.add(blockCNameComboBox);
panel22.add(turnoutEditBlockC = new JButton(rb.getString("CreateEdit")));
turnoutEditBlockC.addActionListener((ActionEvent e) -> {
turnoutEditBlockCPressed(e);
});
turnoutEditBlockC.setToolTipText(Bundle.getMessage("EditBlockHint", "3"));
contentPane.add(panel22);
JPanel panel23 = new JPanel();
panel23.setLayout(new FlowLayout());
TitledBorder borderblk4 = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
borderblk4.setTitle(Bundle.getMessage("BeanNameBlock") + " 4");
panel23.setBorder(borderblk4);
layoutEditor.setupComboBox(blockDNameComboBox, false, true);
blockDNameComboBox.setToolTipText(rb.getString("EditBlockDNameHint"));
panel23.add(blockDNameComboBox);
panel23.add(turnoutEditBlockD = new JButton(rb.getString("CreateEdit")));
turnoutEditBlockD.addActionListener((ActionEvent e) -> {
turnoutEditBlockDPressed(e);
});
turnoutEditBlockD.setToolTipText(Bundle.getMessage("EditBlockHint", "4"));
contentPane.add(panel23);
}
// set up Edit Block, Done and Cancel buttons
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
// Edit Block
// empty value for block 1
turnoutEditBlock.setToolTipText(Bundle.getMessage("EditBlockHint", ""));
// Done
panel5.add(turnoutEditDone = new JButton(Bundle.getMessage("ButtonDone")));
// make this button the default button (return or enter activates)
// Note: We have to invoke this later because we don't currently have a root pane
SwingUtilities.invokeLater(() -> {
JRootPane rootPane = SwingUtilities.getRootPane(turnoutEditDone);
rootPane.setDefaultButton(turnoutEditDone);
});
turnoutEditDone.addActionListener((ActionEvent e) -> {
turnoutEditDonePressed(e);
});
turnoutEditDone.setToolTipText(Bundle.getMessage("DoneHint", Bundle.getMessage("ButtonDone")));
// Cancel
panel5.add(turnoutEditCancel = new JButton(Bundle.getMessage("ButtonCancel")));
turnoutEditCancel.addActionListener((ActionEvent e) -> {
turnoutEditCancelPressed(e);
});
turnoutEditCancel.setToolTipText(Bundle.getMessage("CancelHint", Bundle.getMessage("ButtonCancel")));
contentPane.add(panel5);
}
hiddenBox.setSelected(hidden);
// Set up for Edit
blockNameComboBox.getEditor().setItem(blockName);
if ((type == DOUBLE_XOVER) || (type == RH_XOVER) || (type == LH_XOVER)) {
blockBNameComboBox.getEditor().setItem(blockBName);
blockCNameComboBox.getEditor().setItem(blockCName);
blockDNameComboBox.getEditor().setItem(blockDName);
}
firstTurnoutComboBox.setSelectedItem(turnoutName);
if (secondNamedTurnout != null) {
additionalTurnout.setSelected(true);
secondTurnoutLabel.setEnabled(true);
secondTurnoutComboBox.setEnabled(true);
}
if ((type != DOUBLE_XOVER) && (type != RH_XOVER) && (type != LH_XOVER)) {
if (continuingSense == Turnout.CLOSED) {
stateBox.setSelectedIndex(turnoutClosedIndex);
} else {
stateBox.setSelectedIndex(turnoutThrownIndex);
}
}
editLayoutTurnoutFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
turnoutEditCancelPressed(null);
}
});
editLayoutTurnoutFrame.pack();
editLayoutTurnoutFrame.setVisible(true);
editOpen = true;
needsBlockUpdate = false;
}
use of javax.swing.border.TitledBorder in project JMRI by JMRI.
the class VSDecoderPane method initComponents.
/**
* initComponents()
*
* initialzies the GUI components.
*/
@Override
public void initComponents() {
log.debug("initComponents()");
//buildMenu();
setLayout(new GridBagLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
// Add the tabbed pane to the VSDecoderPane. The tabbedPane will contain all the other panes.
tabbedPane = new JTabbedPane();
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.gridx = 0;
gbc1.gridy = 0;
gbc1.fill = GridBagConstraints.BOTH;
gbc1.anchor = GridBagConstraints.CENTER;
gbc1.weightx = 1.0;
gbc1.weighty = 1.0;
this.add(tabbedPane, gbc1);
//-------------------------------------------------------------------
// configPanel
// The configPanel holds the stuff for addressing and configuration.
configPanel = new VSDConfigPanel(decoder_id, this);
tabbedPane.addTab("Config", configPanel);
//-------------------------------------------------------------------
// soundsPanel
// The optionPanel holds controls for selecting sound options.
optionPanel = new VSDOptionPanel(decoder_id, this);
tabbedPane.addTab("Options", optionPanel);
//-------------------------------------------------------------------
// soundsPanel
// The soundsPanel holds buttons for specific sounds.
soundsPanel = new VSDSoundsPanel(decoder_id, this);
tabbedPane.addTab("Sounds", soundsPanel);
//-------------------------------------------------------------------
// volumePanel
// The volumePanel holds the master volume and mute controls.
volumePanel = new JPanel();
volumePanel.setLayout(new BorderLayout(10, 0));
TitledBorder title = BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), "Volume");
title.setTitlePosition(TitledBorder.DEFAULT_POSITION);
volumePanel.setBorder(title);
JSlider volume = new JSlider(0, 100);
volume.setMinorTickSpacing(10);
volume.setPaintTicks(true);
volume.setValue(80);
volume.setPreferredSize(new Dimension(200, 20));
volume.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
volumeChange(e);
}
});
volumePanel.add(volume, BorderLayout.LINE_START);
JToggleButton mute_button = new JToggleButton("Mute");
mute_button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
muteButtonPressed(e);
}
});
volumePanel.add(mute_button, BorderLayout.LINE_END);
GridBagConstraints gbc2 = new GridBagConstraints();
gbc2.gridx = 0;
gbc2.gridy = 1;
gbc2.fill = GridBagConstraints.BOTH;
gbc2.anchor = GridBagConstraints.CENTER;
gbc2.weightx = 1.0;
gbc2.weighty = 0.1;
this.add(volumePanel, gbc2);
//-------------------------------------------------------------------
// statusBar
// The statusBar shows decoder status.
statusBar = new jmri.util.swing.StatusBar();
statusBar.setMessage("Status: No decoder assigned");
GridBagConstraints gbc3 = new GridBagConstraints();
gbc3.gridx = 0;
gbc3.gridy = 2;
gbc3.fill = GridBagConstraints.BOTH;
gbc3.anchor = GridBagConstraints.PAGE_END;
gbc3.weightx = 1.0;
gbc3.weighty = 0.1;
this.add(statusBar, gbc3);
//-------------------------------------------------------------------
// Pack and set visible
parent.pack();
parent.setVisible(true);
}
use of javax.swing.border.TitledBorder in project JMRI by JMRI.
the class PaneProgDp3Action method setUpRosterPanel.
synchronized void setUpRosterPanel() {
re = null;
if (rosterPanel == null) {
rosterPanel = new JPanel();
rosterPanel.setLayout(new BorderLayout());
JPanel p = new JPanel();
// NOI18N
p.add(new JLabel(Bundle.getMessage("RosterId")));
p.add(rosterIdField);
rosterPanel.add(p, BorderLayout.NORTH);
// NOI18N
rosterIdField.setText(SymbolicProgBundle.getMessage("LabelNewDecoder"));
// NOI18N
saveBasicRoster = new JButton(Bundle.getMessage("Save"));
saveBasicRoster.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
log.debug("saveBasicRoster button pressed, calls saveRosterEntry");
saveRosterEntry();
} catch (JmriException ex) {
return;
}
}
});
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
// NOI18N
border.setTitle(Bundle.getMessage("CreateBasicRosterEntry"));
rosterPanel.setBorder(border);
rosterPanel.setVisible(false);
f.getContentPane().add(rosterPanel, BorderLayout.EAST);
} else {
// NOI18N
rosterIdField.setText(SymbolicProgBundle.getMessage("LabelNewDecoder"));
}
if (progPane != null) {
progPane.dispose();
rosterPanel.remove(progPane);
progPane = null;
rosterPanel.revalidate();
f.getContentPane().repaint();
f.repaint();
f.pack();
}
if (jmri.InstanceManager.getNullableDefault(jmri.ProgrammerManager.class) != null && jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).isGlobalProgrammerAvailable()) {
this.mProgrammer = jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer();
}
cvModel = new CvTableModel(statusLabel, mProgrammer);
iCvModel = new IndexedCvTableModel(statusLabel, mProgrammer);
variableModel = new VariableTableModel(statusLabel, new String[] { "Name", "Value" }, cvModel, iCvModel);
if (decoderFile != null) {
Element decoderRoot = null;
try {
decoderRoot = decoderFile.rootFromName(DecoderFile.fileLocation + decoderFile.getFilename());
} catch (JDOMException | IOException e) {
log.error("Exception while loading decoder XML file: " + decoderFile.getFilename(), e);
return;
}
// NOI18N
modelElem = decoderFile.getModelElement();
// NOI18N
decoderFile.loadVariableModel(decoderRoot.getChild("decoder"), variableModel);
rosterPanel.setVisible(true);
} else {
rosterPanel.setVisible(false);
return;
}
Element programmerRoot;
XmlFile pf = new XmlFile() {
};
// XmlFile is abstract
java.beans.PropertyChangeListener dccNews = new java.beans.PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
updateDccAddress();
}
};
// NOI18N
primaryAddr = variableModel.findVar("Short Address");
if (primaryAddr == null) {
// NOI18N
log.debug("DCC Address monitor didnt find a Short Address variable");
} else {
primaryAddr.addPropertyChangeListener(dccNews);
}
// NOI18N
extendAddr = variableModel.findVar("Long Address");
if (extendAddr == null) {
// NOI18N
log.debug("DCC Address monitor didnt find an Long Address variable");
} else {
extendAddr.addPropertyChangeListener(dccNews);
}
// NOI18N
addMode = (EnumVariableValue) variableModel.findVar("Address Format");
if (addMode == null) {
// NOI18N
log.debug("DCC Address monitor didnt find an Address Format variable");
} else {
addMode.addPropertyChangeListener(dccNews);
}
try {
// NOI18N
programmerRoot = pf.rootFromName("programmers" + File.separator + "Basic.xml");
Element base;
if ((base = programmerRoot.getChild("programmer")) == null) {
// NOI18N
// NOI18N
log.error("xml file top element is not programmer");
return;
}
// for all "pane" elements in the programmer
// NOI18N
List<Element> paneList = base.getChildren("pane");
// NOI18N
log.debug("will process {} pane definitions", paneList.size());
String name = jmri.util.jdom.LocaleSelector.getAttribute(paneList.get(0), "name");
progPane = new ThisProgPane(this, name, paneList.get(0), cvModel, iCvModel, variableModel, modelElem);
// NOI18N
progPane.setVariableValue("Short Address", cv1);
// NOI18N
progPane.setVariableValue("Long Address", longAddress);
// NOI18N
progPane.setCVValue("29", cv29);
// NOI18N
progPane.setCVValue("19", cv19);
rosterPanel.add(progPane, BorderLayout.CENTER);
rosterPanel.revalidate();
rosterPanel.setVisible(true);
f.getContentPane().repaint();
f.repaint();
f.pack();
return;
} catch (JDOMException | IOException e) {
// NOI18N
log.error("exception reading programmer file: ", e);
}
}
Aggregations