use of java.awt.GridLayout in project processdash by dtuma.
the class PercentSpentIndicator method showEditEstimateDialog.
private void showEditEstimateDialog() {
if (currentTaskPath == null || estTimeDataName == null || estTimeEditable == false)
return;
ToolTipManager.sharedInstance().mouseExited(new MouseEvent(this, MouseEvent.MOUSE_EXITED, System.currentTimeMillis(), 0, 0, -1, 0, false));
final JTextField estimate = new JTextField();
if (estTime > 0 && !Double.isInfinite(estTime))
estimate.setText(FormatUtil.formatTime(estTime));
String prompt = resources.format("Edit_Dialog.Prompt_FMT", currentTaskPath);
JPanel p = new JPanel(new GridLayout(2, 2, 10, 2));
p.add(new JLabel(resources.getString("Actual_Time_Label"), JLabel.TRAILING));
p.add(new JLabel(FormatUtil.formatTime(actTime)));
p.add(new JLabel(resources.getString("Estimated_Time_Label"), JLabel.TRAILING));
p.add(estimate);
String title = resources.getString("Edit_Dialog.Title");
Object message = new Object[] { prompt, p, new JOptionPaneTweaker.GrabFocus(estimate) };
while (true) {
if (JOptionPane.showConfirmDialog(this, message, title, JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION)
return;
SimpleData newEstimate;
String userInput = estimate.getText();
if (userInput == null || userInput.trim().length() == 0) {
newEstimate = null;
} else {
long l = FormatUtil.parseTime(userInput.trim());
if (l < 0) {
estimate.setBackground(new Color(255, 200, 200));
estimate.setToolTipText(resources.getString("Edit_Dialog.Invalid_Time"));
continue;
}
newEstimate = new DoubleData(l, true);
}
dashCtx.getData().userPutValue(estTimeDataName, newEstimate);
EST_TIME_JANITOR.cleanup(dashCtx);
return;
}
}
use of java.awt.GridLayout in project processdash by dtuma.
the class RolesEditor method createUI.
private Component createUI() {
// create the roles button panel
JPanel roleButtons = new JPanel(new GridLayout(2, 2, 5, 5));
roleButtons.add(new JButton(new AddRoleAction()));
roleButtons.add(new JButton(new CopyRoleAction()));
roleButtons.add(new JButton(new RenameRoleAction()));
roleButtons.add(new JButton(new DeleteRoleAction()));
// create the permissions button panel
JPanel permButtons = new JPanel(new GridLayout(1, 4, 5, 5));
permButtons.add(new JButton(new AddPermissionAction()));
permButtons.add(new JButton(new EditPermissionAction()));
permButtons.add(new JButton(new DeletePermissionAction()));
permButtons.add(new JButton(new RevertPermissionsAction()));
// read the known roles, and add them to a list
roles = new DefaultListModel();
for (Role r : PermissionsManager.getInstance().getAllRoles()) roles.addElement(r);
rolesList = new JList(roles);
rolesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
rolesList.addListSelectionListener(new RoleSelectionHandler());
JScrollPane rsp = new JScrollPane(rolesList);
int prefHeight = Math.max(rolesList.getCellBounds(0, 0).height * 15 + 6, 200);
rsp.setPreferredSize(new Dimension(200, prefHeight));
// create an object for editing the permissions in the selected role
permissionList = new PermissionList();
permissionList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
permissionList.getSelectionModel().addListSelectionListener(new PermissionSelectionHandler());
JScrollPane psp = new JScrollPane(permissionList);
psp.setPreferredSize(new Dimension(450, prefHeight));
// create titles to display on the dialog
JLabel rolesTitle = new JLabel(resources.getString("Roles_Header"));
JLabel permissionsTitle = new JLabel(resources.getString("Permissions_Header"));
Font f = rolesTitle.getFont();
f = f.deriveFont(f.getSize2D() * 1.5f);
rolesTitle.setFont(f);
permissionsTitle.setFont(f);
Border b = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black);
rolesTitle.setBorder(b);
permissionsTitle.setBorder(b);
// arrange the components onto a panel
GridBagLayout layout = new GridBagLayout();
userInterface = new JPanel(layout);
GridBagConstraints c = new GridBagConstraints();
c.gridx = c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
layout.addLayoutComponent(rolesTitle, c);
userInterface.add(rolesTitle);
c.gridx = 2;
Component comp = BoxUtils.hbox(new JOptionPaneTweaker.MakeResizable(), new JOptionPaneTweaker.DisableKeys());
layout.addLayoutComponent(comp, c);
userInterface.add(comp);
c.gridx = 1;
c.insets = new Insets(0, 10, 0, 0);
layout.addLayoutComponent(permissionsTitle, c);
userInterface.add(permissionsTitle);
c.gridx = 0;
c.gridy = 1;
c.gridheight = 2;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 20, 0, 0);
if (editable) {
layout.addLayoutComponent(roleButtons, c);
userInterface.add(roleButtons);
}
c.gridy = 3;
c.gridheight = 1;
c.weightx = c.weighty = 1.0;
layout.addLayoutComponent(rsp, c);
userInterface.add(rsp);
c.gridx = c.gridy = 1;
c.weightx = c.weighty = 0;
c.insets = new Insets(10, 30, 0, 0);
if (editable) {
layout.addLayoutComponent(permButtons, c);
userInterface.add(permButtons);
}
c.gridy = 2;
c.gridheight = 2;
c.weightx = 3.0;
c.weighty = 1.0;
layout.addLayoutComponent(psp, c);
userInterface.add(psp);
// load the preferred size of the window
try {
String[] size = Settings.getVal(SIZE_PREF).split(",");
Dimension d = new Dimension(Integer.parseInt(size[0]), Integer.parseInt(size[1]));
userInterface.setPreferredSize(d);
} catch (Exception e) {
}
return userInterface;
}
use of java.awt.GridLayout in project JMRI by JMRI.
the class MemoryFrameAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
nf = java.text.NumberFormat.getInstance();
nf.setMinimumFractionDigits(3);
nf.setMaximumFractionDigits(3);
nf.setGroupingUsed(false);
JmriJFrame f = new JmriJFrame(Bundle.getMessage("Memory_Usage_Monitor"));
Container p = f.getContentPane();
p.setLayout(new GridLayout(5, 3));
p.add(new JLabel(Bundle.getMessage("used_(MB)")));
p.add(new JLabel(Bundle.getMessage("free_(MB)")));
p.add(new JLabel(Bundle.getMessage("total_(MB,_of_") + " " + nf.format(Runtime.getRuntime().maxMemory() / (1024. * 1024.)) + "MB)"));
p.add(used3);
p.add(free3);
p.add(total3);
p.add(used2);
p.add(free2);
p.add(total2);
p.add(used1);
p.add(free1);
p.add(total1);
p.add(updateButton);
p.add(gcButton);
p.add(testButton);
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
updateDisplay();
}
});
gcButton.addActionListener(new ActionListener() {
// Garbage collection OK here
@SuppressFBWarnings(value = "DM_GC")
@Override
public void actionPerformed(ActionEvent event) {
Runtime.getRuntime().gc();
updateDisplay();
}
});
testButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
Roster.getDefault();
DecoderIndexFile.instance();
updateDisplay();
}
});
f.addHelpMenu("package.jmri.jmrit.MemoryFrameAction", true);
f.pack();
f.setVisible(true);
}
use of java.awt.GridLayout in project JMRI by JMRI.
the class LocoGenPanel method initComponents.
@Override
public void initComponents() throws Exception {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
// handle single-packet part
add(new JLabel("Send one packet:"));
{
JPanel pane1 = new JPanel();
pane1.setLayout(new BoxLayout(pane1, BoxLayout.Y_AXIS));
jLabel1.setText("Packet:");
jLabel1.setVisible(true);
sendButton.setText("Send");
sendButton.setVisible(true);
sendButton.setToolTipText("Send packet");
packetTextField.setToolTipText("Enter packet as hex pairs, e.g. 82 7D; checksum should be present but is recalculated");
pane1.add(jLabel1);
pane1.add(packetTextField);
pane1.add(sendButton);
pane1.add(Box.createVerticalGlue());
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
sendButtonActionPerformed(e);
}
});
add(pane1);
}
add(new JSeparator());
// Configure the sequence
add(new JLabel("Send sequence of packets:"));
JPanel pane2 = new JPanel();
pane2.setLayout(new GridLayout(MAXSEQUENCE + 2, 4));
pane2.add(new JLabel(""));
pane2.add(new JLabel("Send"));
pane2.add(new JLabel("packet"));
pane2.add(new JLabel("wait (msec)"));
for (int i = 0; i < MAXSEQUENCE; i++) {
pane2.add(new JLabel(Integer.toString(i + 1)));
mUseField[i] = new JCheckBox();
mPacketField[i] = new JTextField(10);
mDelayField[i] = new JTextField(10);
pane2.add(mUseField[i]);
pane2.add(mPacketField[i]);
pane2.add(mDelayField[i]);
}
// starts a new row in layout
pane2.add(mRunButton);
add(pane2);
mRunButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
runButtonActionPerformed(e);
}
});
}
use of java.awt.GridLayout in project jdk8u_jdk by JetBrains.
the class FileDialogForDirectories method init.
@Override
public void init() {
if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
Sysout.createDialogWithInstructions(new String[] { "Press PASS, this test is for MacOS X only." });
return;
}
System.setProperty("apple.awt.fileDialogForDirectories", "true");
setLayout(new GridLayout(1, 1));
fd = new FileDialog(new Frame(), "Open");
showBtn = new Button("Show File Dialog");
showBtn.addActionListener(this);
add(showBtn);
String[] instructions = { "1) Click on 'Show File Dialog' button. A file dialog will come up.", "2) Check that files can't be selected.", "3) Check that directories can be selected.", "4) Repeat steps 1 - 3 a few times for different files and directories.", "5) If it's true then the test passed, otherwise it failed." };
Sysout.createDialogWithInstructions(instructions);
}
Aggregations