use of java.awt.event.FocusListener in project jgnash by ccavanaugh.
the class SellSharePanel method registerListeners.
private void registerListeners() {
FocusListener focusListener = new FocusAdapter() {
@Override
public void focusLost(final FocusEvent evt) {
updateTotalField();
}
};
feePanel.addFocusListener(focusListener);
feePanel.addActionListener(this);
gainsPanel.addActionListener(this);
quantityField.addFocusListener(focusListener);
priceField.addFocusListener(focusListener);
datePanel.getDateField().addKeyListener(keyListener);
feePanel.addKeyListener(keyListener);
memoField.addKeyListener(keyListener);
priceField.addKeyListener(keyListener);
quantityField.addKeyListener(keyListener);
securityCombo.addKeyListener(keyListener);
getReconcileCheckBox().addKeyListener(keyListener);
}
use of java.awt.event.FocusListener in project JMRI by JMRI.
the class AbstractStreamConnectionConfig method checkInitDone.
@SuppressWarnings("unchecked")
@Override
protected void checkInitDone() {
if (log.isDebugEnabled()) {
log.debug("init called for " + name());
}
if (init) {
return;
}
if (adapter.getSystemConnectionMemo() != null) {
systemPrefixField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!adapter.getSystemConnectionMemo().setSystemPrefix(systemPrefixField.getText())) {
JOptionPane.showMessageDialog(null, "System Prefix " + systemPrefixField.getText() + " is already assigned");
systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
}
}
});
systemPrefixField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (!adapter.getSystemConnectionMemo().setSystemPrefix(systemPrefixField.getText())) {
JOptionPane.showMessageDialog(null, "System Prefix " + systemPrefixField.getText() + " is already assigned");
systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
connectionNameField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!adapter.getSystemConnectionMemo().setUserName(connectionNameField.getText())) {
JOptionPane.showMessageDialog(null, "Connection Name " + connectionNameField.getText() + " is already assigned");
connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
}
}
});
connectionNameField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (!adapter.getSystemConnectionMemo().setUserName(connectionNameField.getText())) {
JOptionPane.showMessageDialog(null, "Connection Name " + connectionNameField.getText() + " is already assigned");
connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
for (String i : options.keySet()) {
final String item = i;
if (options.get(i).getComponent() instanceof JComboBox) {
((JComboBox<?>) options.get(i).getComponent()).addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adapter.setOptionState(item, options.get(item).getItem());
}
});
}
}
}
init = true;
}
use of java.awt.event.FocusListener in project JMRI by JMRI.
the class AddSignalMastPanel method updateDCCMastPanel.
void updateDCCMastPanel() {
if ((!Bundle.getMessage("DCCMast").equals(signalMastDriver.getSelectedItem())) && (!Bundle.getMessage("LNCPMast").equals(signalMastDriver.getSelectedItem()))) {
return;
}
dccAspect = new HashMap<String, DCCAspectPanel>(10);
java.util.List<jmri.CommandStation> connList = jmri.InstanceManager.getList(jmri.CommandStation.class);
systemPrefixBox.removeAllItems();
if (!connList.isEmpty()) {
for (int x = 0; x < connList.size(); x++) {
jmri.CommandStation station = connList.get(x);
if (Bundle.getMessage("LNCPMast").equals(signalMastDriver.getSelectedItem())) {
if (station instanceof jmri.jmrix.loconet.SlotManager) {
systemPrefixBox.addItem(station.getUserName());
}
} else {
systemPrefixBox.addItem(station.getUserName());
}
}
} else {
systemPrefixBox.addItem("None");
}
String mastType = mastNames.get(mastBox.getSelectedIndex()).getName();
mastType = mastType.substring(11, mastType.indexOf(".xml"));
jmri.implementation.DefaultSignalAppearanceMap sigMap = jmri.implementation.DefaultSignalAppearanceMap.getMap(sigsysname, mastType);
java.util.Enumeration<String> aspects = sigMap.getAspects();
SignalSystem sigsys = InstanceManager.getDefault(jmri.SignalSystemManager.class).getSystem(sigsysname);
while (aspects.hasMoreElements()) {
String aspect = aspects.nextElement();
DCCAspectPanel aPanel = new DCCAspectPanel(aspect);
dccAspect.put(aspect, aPanel);
aPanel.setAspectId((String) sigsys.getProperty(aspect, "dccAspect"));
}
dccMastPanel.removeAll();
dccMastPanel.setLayout(new jmri.util.javaworld.GridLayout2(dccAspect.size() + 3, 2));
dccMastPanel.add(systemPrefixBoxLabel);
dccMastPanel.add(systemPrefixBox);
dccMastPanel.add(dccAspectAddressLabel);
dccMastPanel.add(dccAspectAddressField);
if (dccAddressListener == null) {
dccAddressListener = new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (dccAspectAddressField.getText().equals("")) {
return;
}
validateDCCAddress();
}
@Override
public void focusGained(FocusEvent e) {
}
};
dccAspectAddressField.addFocusListener(dccAddressListener);
}
if (mast == null) {
systemPrefixBoxLabel.setEnabled(true);
systemPrefixBox.setEnabled(true);
dccAspectAddressLabel.setEnabled(true);
dccAspectAddressField.setEnabled(true);
}
for (String aspect : dccAspect.keySet()) {
// load aspect panels from hashmap
dccMastPanel.add(dccAspect.get(aspect).getPanel());
}
if ((dccAspect.size() & 1) == 1) {
// spacer
dccMastPanel.add(new JLabel());
}
dccMastPanel.add(new JLabel(Bundle.getMessage("DCCMastCopyAspectId") + ":"));
dccMastPanel.add(copyFromMastSelection());
}
use of java.awt.event.FocusListener in project JMRI by JMRI.
the class JsonNetworkConnectionConfig method checkInitDone.
@Override
protected void checkInitDone() {
super.checkInitDone();
//options.put(Bundle.getMessage("DiscoveredServices"), new Option(Bundle.getMessage("DiscoveredServices"), services, false));
if (this.adapter.getSystemConnectionMemo() != null) {
final JsonClientSystemConnectionMemo memo = (JsonClientSystemConnectionMemo) this.adapter.getSystemConnectionMemo();
this.transmitPrefixField.setText(memo.getTransmitPrefix());
this.transmitPrefixField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
memo.setTransmitPrefix(transmitPrefixField.getText());
transmitPrefixField.setText(memo.getTransmitPrefix());
}
});
this.transmitPrefixField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
memo.setTransmitPrefix(transmitPrefixField.getText());
transmitPrefixField.setText(memo.getTransmitPrefix());
}
@Override
public void focusGained(FocusEvent e) {
// nothing to do
}
});
this.nodeIdentityField.setText(memo.getNodeIdentity());
this.nodeIdentityField.setToolTipText(Bundle.getMessage("NodeIdentityToolTip"));
}
}
use of java.awt.event.FocusListener 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) {
}
});
}
Aggregations