use of java.awt.Label in project voltdb by VoltDB.
the class ConnectionDialog method create.
private void create() {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setLayout(new BorderLayout());
Panel p = new Panel(new BorderLayout());
Panel pLabel;
Panel pText;
Panel pButton;
Panel pClearButton;
// (ulrivo): full size on screen with less than 640 width
if (d.width >= 640) {
pLabel = new Panel(new GridLayout(8, 1, 10, 10));
pText = new Panel(new GridLayout(8, 1, 10, 10));
pButton = new Panel(new GridLayout(1, 2, 10, 10));
pClearButton = new Panel(new GridLayout(8, 1, 10, 10));
} else {
pLabel = new Panel(new GridLayout(8, 1));
pText = new Panel(new GridLayout(8, 1));
pButton = new Panel(new GridLayout(1, 2));
pClearButton = new Panel(new GridLayout(8, 1));
}
p.add("West", pLabel);
p.add("Center", pText);
p.add("South", pButton);
p.add("North", createLabel(""));
p.add("East", pClearButton);
p.setBackground(SystemColor.control);
pText.setBackground(SystemColor.control);
pLabel.setBackground(SystemColor.control);
pButton.setBackground(SystemColor.control);
pLabel.add(createLabel("Recent:"));
recent = new Choice();
try {
settings = ConnectionDialogCommon.loadRecentConnectionSettings();
} catch (java.io.IOException ioe) {
ioe.printStackTrace();
}
recent.add(ConnectionDialogCommon.emptySettingName);
Enumeration en = settings.elements();
while (en.hasMoreElements()) {
recent.add(((ConnectionSetting) en.nextElement()).getName());
}
recent.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String s = (String) e.getItem();
ConnectionSetting setting = (ConnectionSetting) settings.get(s);
if (setting != null) {
mName.setText(setting.getName());
mDriver.setText(setting.getDriver());
mURL.setText(setting.getUrl());
mUser.setText(setting.getUser());
mPassword.setText(setting.getPassword());
}
}
});
pText.add(recent);
Button b;
b = new Button("Clr");
b.setActionCommand("Clear");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ConnectionDialogCommon.deleteRecentConnectionSettings();
settings = new Hashtable();
recent.removeAll();
recent.add(ConnectionDialogCommon.emptySettingName);
mName.setText(null);
}
});
pClearButton.add(b);
pLabel.add(createLabel("Setting Name:"));
mName = new TextField("");
pText.add(mName);
pLabel.add(createLabel("Type:"));
types = new Choice();
connTypes = ConnectionDialogCommon.getTypes();
for (int i = 0; i < connTypes.length; i++) {
types.add(connTypes[i][0]);
}
types.addItemListener(this);
pText.add(types);
pLabel.add(createLabel("Driver:"));
mDriver = new TextField(connTypes[0][1]);
pText.add(mDriver);
pLabel.add(createLabel("URL:"));
mURL = new TextField(connTypes[0][2]);
mURL.addActionListener(this);
pText.add(mURL);
pLabel.add(createLabel("User:"));
mUser = new TextField("SA");
mUser.addActionListener(this);
pText.add(mUser);
pLabel.add(createLabel("Password:"));
mPassword = new TextField("");
mPassword.addActionListener(this);
mPassword.setEchoChar('*');
pText.add(mPassword);
b = new Button("Ok");
b.setActionCommand("ConnectOk");
b.addActionListener(this);
pButton.add(b);
b = new Button("Cancel");
b.setActionCommand("ConnectCancel");
b.addActionListener(this);
pButton.add(b);
add("East", createLabel(""));
add("West", createLabel(""));
mError = new Label("");
Panel pMessage = createBorderPanel(mError);
add("South", pMessage);
add("North", createLabel(""));
add("Center", p);
doLayout();
pack();
Dimension size = getSize();
// (ulrivo): full size on screen with less than 640 width
if (d.width >= 640) {
setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
} else {
setLocation(0, 0);
setSize(d);
}
show();
}
use of java.awt.Label in project voltdb by VoltDB.
the class ZaurusConnectionDialog method create.
/**
* Method declaration
*
*/
void create(Insets defInsets) {
setLayout(new BorderLayout());
addKeyListener(this);
Panel p = new Panel(new GridLayout(6, 2, 10, 10));
p.addKeyListener(this);
p.setBackground(SystemColor.control);
p.add(createLabel("Type:"));
Choice types = new Choice();
types.addItemListener(this);
types.addKeyListener(this);
for (int i = 0; i < sJDBCTypes.length; i++) {
types.add(sJDBCTypes[i][0]);
}
p.add(types);
p.add(createLabel("Driver:"));
mDriver = new TextField("org.hsqldb_voltpatches.jdbcDriver");
mDriver.addKeyListener(this);
p.add(mDriver);
p.add(createLabel("URL:"));
mURL = new TextField("jdbc:hsqldb:mem:.");
mURL.addKeyListener(this);
p.add(mURL);
p.add(createLabel("User:"));
mUser = new TextField("SA");
mUser.addKeyListener(this);
p.add(mUser);
p.add(createLabel("Password:"));
mPassword = new TextField("");
mPassword.addKeyListener(this);
mPassword.setEchoChar('*');
p.add(mPassword);
Button b;
b = new Button("Cancel");
b.setActionCommand("ConnectCancel");
b.addActionListener(this);
b.addKeyListener(this);
p.add(b);
b = new Button("Ok");
b.setActionCommand("ConnectOk");
b.addActionListener(this);
b.addKeyListener(this);
p.add(b);
setLayout(new BorderLayout());
add("East", createLabel(" "));
add("West", createLabel(" "));
mError = new Label("");
Panel pMessage = createBorderPanel(mError);
pMessage.addKeyListener(this);
add("South", pMessage);
add("North", createLabel(""));
add("Center", p);
doLayout();
pack();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = getSize();
if (d.width > 640) {
setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
} else if (defInsets.top > 0 && defInsets.left > 0) {
setLocation(defInsets.bottom, defInsets.right);
setSize(defInsets.top, defInsets.left);
// full size on screen with less than 640 width
} else {
setLocation(0, 0);
setSize(d);
}
show();
}
use of java.awt.Label in project voltdb by VoltDB.
the class Transfer method createLabel.
/**
* Method declaration
*
*
* @param s
*/
private Label createLabel(String s) {
Label l = new Label(s);
l.setBackground(SystemColor.control);
return l;
}
use of java.awt.Label in project voltdb by VoltDB.
the class ZaurusTableForm method initGUI.
private void initGUI() {
Panel pEntry = new Panel();
pEntry.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(3, 3, 3, 3);
c.gridwidth = 1;
c.gridheight = 1;
c.weightx = c.weighty = 1;
c.anchor = GridBagConstraints.WEST;
komponente = new ZaurusComponent[columns.length];
for (int i = 0; i < columns.length; i++) {
c.gridy = i;
c.gridx = 0;
pEntry.add(new Label((String) columns[i]), c);
c.gridx = 1;
int constraint = this.getConstraintIndex(i);
if (constraint >= 0 && imColIndex[constraint].length == 1) {
// we use ony foreign keys with one index
ZaurusChoice tmp = new ZaurusChoice();
this.fillZChoice(tmp, refTables[constraint], refColumns[constraint][0]);
tmp.addItemListener(this);
komponente[i] = tmp;
pEntry.add(tmp, c);
} else if (columnTypes[i] == java.sql.Types.DATE) {
// System.out.println("hier gibt es eine Date-Spalte namens "+columns[i]);
ZaurusTextField tmp = new ZaurusTextField(8);
tmp.addTextListener(this);
pEntry.add(tmp, c);
komponente[i] = tmp;
} else {
ZaurusTextField tmp = new ZaurusTextField(5);
tmp.addTextListener(this);
pEntry.add(tmp, c);
komponente[i] = tmp;
}
komponente[i].setEditable(true);
}
this.add(pEntry);
}
use of java.awt.Label in project JMRI by JMRI.
the class LayoutSlip method editLayoutSlip.
/**
* Edit a Slip
*/
protected void editLayoutSlip(LayoutTurnout o) {
if (editOpen) {
editLayoutTurnoutFrame.setVisible(true);
return;
}
// Initialize if needed
if (editLayoutTurnoutFrame == null) {
editLayoutTurnoutFrame = new JmriJFrame(rb.getString("EditSlip"), false, true);
editLayoutTurnoutFrame.addHelpMenu("package.jmri.jmrit.display.EditLayoutSlip", true);
editLayoutTurnoutFrame.setLocation(50, 30);
Container contentPane = editLayoutTurnoutFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel turnoutNameLabel = new JLabel(Bundle.getMessage("BeanNameTurnout") + " A " + Bundle.getMessage("Name"));
turnoutAComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getTurnout(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
panel1.add(turnoutNameLabel);
panel1.add(turnoutAComboBox);
contentPane.add(panel1);
JPanel panel1a = new JPanel();
panel1a.setLayout(new FlowLayout());
JLabel turnoutBNameLabel = new JLabel(Bundle.getMessage("BeanNameTurnout") + " B " + Bundle.getMessage("Name"));
turnoutBComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getTurnoutB(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
panel1a.add(turnoutBNameLabel);
panel1a.add(turnoutBComboBox);
contentPane.add(panel1a);
JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayout(0, 3, 2, 2));
panel2.add(new Label(" "));
panel2.add(new Label(Bundle.getMessage("BeanNameTurnout") + " A:"));
panel2.add(new Label(Bundle.getMessage("BeanNameTurnout") + " B:"));
for (Entry<Integer, TurnoutState> ts : turnoutStates.entrySet()) {
SampleStates draw = new SampleStates(ts.getKey());
draw.repaint();
draw.setPreferredSize(new Dimension(40, 40));
panel2.add(draw);
panel2.add(ts.getValue().getComboA());
panel2.add(ts.getValue().getComboB());
}
testPanel = new TestState();
testPanel.setSize(40, 40);
testPanel.setPreferredSize(new Dimension(40, 40));
panel2.add(testPanel);
JButton testButton = new JButton("Test");
testButton.addActionListener((ActionEvent e) -> {
toggleStateTest();
});
panel2.add(testButton);
contentPane.add(panel2);
JPanel panel33 = new JPanel();
panel33.setLayout(new FlowLayout());
hiddenBox.setToolTipText(rb.getString("HiddenToolTip"));
panel33.add(hiddenBox);
contentPane.add(panel33);
// setup block name
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout());
JLabel block1NameLabel = new JLabel(rb.getString("BlockID"));
panel3.add(block1NameLabel);
panel3.add(blockNameComboBox);
layoutEditor.setupComboBox(blockNameComboBox, false, true);
blockNameComboBox.setToolTipText(rb.getString("EditBlockNameHint"));
contentPane.add(panel3);
// set up Edit Block buttons
JPanel panel4 = new JPanel();
panel4.setLayout(new FlowLayout());
// Edit Block
panel4.add(turnoutEditBlock = new JButton(Bundle.getMessage("EditBlock", "")));
turnoutEditBlock.addActionListener((ActionEvent event) -> {
turnoutEditBlockPressed(event);
});
// empty value for block 1
turnoutEditBlock.setToolTipText(Bundle.getMessage("EditBlockHint", ""));
contentPane.add(panel4);
// set up Done and Cancel buttons
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
panel5.add(slipEditDone = 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(slipEditDone);
rootPane.setDefaultButton(slipEditDone);
});
slipEditDone.addActionListener((ActionEvent event) -> {
slipEditDonePressed(event);
});
slipEditDone.setToolTipText(Bundle.getMessage("DoneHint", Bundle.getMessage("ButtonDone")));
// Cancel
panel5.add(slipEditCancel = new JButton(Bundle.getMessage("ButtonCancel")));
slipEditCancel.addActionListener((ActionEvent event) -> {
slipEditCancelPressed(event);
});
slipEditCancel.setToolTipText(Bundle.getMessage("CancelHint", Bundle.getMessage("ButtonCancel")));
contentPane.add(panel5);
}
hiddenBox.setSelected(hidden);
// Set up for Edit
blockNameComboBox.getEditor().setItem(blockName);
editLayoutTurnoutFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
slipEditCancelPressed(null);
}
});
editLayoutTurnoutFrame.pack();
editLayoutTurnoutFrame.setVisible(true);
editOpen = true;
needsBlockUpdate = false;
}
Aggregations