List of usage examples for com.jgoodies.forms.layout FormLayout setRowGroups
public void setRowGroups(int[][] groupOfIndices)
From source file:edu.umich.robot.GuiApplication.java
License:Open Source License
/** * <p>//from w w w .j av a 2s .co m * Pops up a window to create a new splinter robot to add to the simulation. */ public void createSplinterRobotDialog() { final Pose pose = new Pose(); FormLayout layout = new FormLayout("right:pref, 4dlu, 30dlu, 4dlu, right:pref, 4dlu, 30dlu", "pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3 } }); final JDialog dialog = new JDialog(frame, "Create Splinter Robot", true); dialog.setLayout(layout); final JTextField name = new JTextField(); final JTextField x = new JTextField(Double.toString((pose.getX()))); final JTextField y = new JTextField(Double.toString((pose.getY()))); final JButton cancel = new JButton("Cancel"); final JButton ok = new JButton("OK"); CellConstraints cc = new CellConstraints(); dialog.add(new JLabel("Name"), cc.xy(1, 1)); dialog.add(name, cc.xyw(3, 1, 5)); dialog.add(new JLabel("x"), cc.xy(1, 3)); dialog.add(x, cc.xy(3, 3)); dialog.add(new JLabel("y"), cc.xy(5, 3)); dialog.add(y, cc.xy(7, 3)); dialog.add(cancel, cc.xyw(1, 5, 3)); dialog.add(ok, cc.xyw(5, 5, 3)); x.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setX(Double.parseDouble(x.getText())); } catch (NumberFormatException ex) { x.setText(Double.toString(pose.getX())); } } }); y.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setY(Double.parseDouble(y.getText())); } catch (NumberFormatException ex) { y.setText(Double.toString(pose.getX())); } } }); final ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String robotName = name.getText().trim(); if (robotName.isEmpty()) { logger.error("Create splinter: robot name empty"); return; } for (char c : robotName.toCharArray()) if (!Character.isDigit(c) && !Character.isLetter(c)) { logger.error("Create splinter: illegal robot name"); return; } controller.createSplinterRobot(robotName, pose, true); controller.createSimSplinter(robotName); controller.createSimLaser(robotName); dialog.dispose(); } }; name.addActionListener(okListener); x.addActionListener(okListener); y.addActionListener(okListener); ok.addActionListener(okListener); ActionListener cancelAction = new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); }
From source file:edu.umich.robot.GuiApplication.java
License:Open Source License
public void createSuperdroidRobotDialog() { final Pose pose = new Pose(); FormLayout layout = new FormLayout("right:pref, 4dlu, 30dlu, 4dlu, right:pref, 4dlu, 30dlu", "pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3 } }); final JDialog dialog = new JDialog(frame, "Create Superdroid Robot", true); dialog.setLayout(layout);/*from w w w . j a v a 2 s .c o m*/ final JTextField name = new JTextField(); final JTextField x = new JTextField(Double.toString((pose.getX()))); final JTextField y = new JTextField(Double.toString((pose.getY()))); final JButton cancel = new JButton("Cancel"); final JButton ok = new JButton("OK"); CellConstraints cc = new CellConstraints(); dialog.add(new JLabel("Name"), cc.xy(1, 1)); dialog.add(name, cc.xyw(3, 1, 5)); dialog.add(new JLabel("x"), cc.xy(1, 3)); dialog.add(x, cc.xy(3, 3)); dialog.add(new JLabel("y"), cc.xy(5, 3)); dialog.add(y, cc.xy(7, 3)); dialog.add(cancel, cc.xyw(1, 5, 3)); dialog.add(ok, cc.xyw(5, 5, 3)); x.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setX(Double.parseDouble(x.getText())); } catch (NumberFormatException ex) { x.setText(Double.toString(pose.getX())); } } }); y.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setY(Double.parseDouble(y.getText())); } catch (NumberFormatException ex) { y.setText(Double.toString(pose.getX())); } } }); final ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String robotName = name.getText().trim(); if (robotName.isEmpty()) { logger.error("Create Superdroid: robot name empty"); return; } for (char c : robotName.toCharArray()) if (!Character.isDigit(c) && !Character.isLetter(c)) { logger.error("Create Superdroid: illegal robot name"); return; } controller.createSuperdroidRobot(robotName, pose, true); controller.createSimSuperdroid(robotName); dialog.dispose(); } }; name.addActionListener(okListener); x.addActionListener(okListener); y.addActionListener(okListener); ok.addActionListener(okListener); ActionListener cancelAction = new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); }
From source file:jgnash.ui.recurring.DayTab.java
License:Open Source License
private void layoutMainPanel() { FormLayout layout = new FormLayout("right:p, $lcgap, f:p, 2dlu, max(48dlu;min), 2dlu, f:p", "f:p, $lgap, f:p, $lgap, f:p"); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); setLayout(layout);/*from w w w . j av a 2s .com*/ setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); noEndButton = new JRadioButton(rb.getString("Button.NoEndDate")); endButton = new JRadioButton(); endDateField = new DatePanel(); group.add(noEndButton); group.add(endButton); numberSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 365, 1)); add(new JLabel(rb.getString("Label.Every")), cc.xy(1, 1)); add(numberSpinner, cc.xywh(3, 1, 3, 1)); add(new JLabel(rb.getString("Tab.Day")), cc.xy(7, 1)); add(new JLabel(rb.getString("Label.EndOn")), cc.xy(1, 3)); add(noEndButton, cc.xywh(3, 3, 5, 1)); add(endButton, cc.xy(3, 5)); add(endDateField, cc.xy(5, 5)); }
From source file:jgnash.ui.recurring.MonthTab.java
License:Open Source License
private void layoutMainPanel() { FormLayout layout = new FormLayout( "right:p, $lcgap, f:p, 2dlu, max(48dlu;min), 2dlu, f:p, 10dlu, right:p, 4dlu, max(48dlu;min)", "f:p, $lgap, f:p, $lgap, f:p"); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); setLayout(layout);/* ww w . j a va 2 s .co m*/ setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); noEndButton = new JRadioButton(rb.getString("Button.NoEndDate")); endButton = new JRadioButton(); endDateField = new DatePanel(); group.add(noEndButton); group.add(endButton); numberSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 24, 1)); typeComboBox = new JComboBox<>(); typeComboBox.setModel(new DefaultComboBoxModel<>( new String[] { rb.getString("Column.Date"), rb.getString("Column.Day") })); add(new JLabel(rb.getString("Label.Every")), cc.xy(1, 1)); add(numberSpinner, cc.xywh(3, 1, 3, 1)); add(new JLabel(rb.getString("Tab.Month")), cc.xy(7, 1)); add(new JLabel(rb.getString("Label.By")), cc.xy(9, 1)); add(typeComboBox, cc.xy(11, 1)); add(new JLabel(rb.getString("Label.EndOn")), cc.xy(1, 3)); add(noEndButton, cc.xyw(3, 3, 5)); add(endButton, cc.xy(3, 5)); add(endDateField, cc.xy(5, 5)); }
From source file:jgnash.ui.recurring.RecurringEntryDialog.java
License:Open Source License
private JPanel createTransactionPanel() { FormLayout layout = new FormLayout("left:p, 4dlu, p:g, 4dlu, p", "f:p, 3dlu, f:p, 3dlu, f:p, 3dlu, f:40dlu:g"); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); CellConstraints cc = new CellConstraints(); JPanel p = new JPanel(layout); descriptionField = new JTextFieldEx(); accountCombo = new AccountListComboBox(); notesArea = new JTextArea(5, 20); notesArea.setLineWrap(true);//ww w .j av a 2 s .co m notesArea.setAutoscrolls(true); JScrollPane pane = new JScrollPane(notesArea); pane.setAutoscrolls(true); transactionField = new JTextFieldEx(); transactionField.setEditable(false); editButton = new JButton(rb.getString("Button.Edit")); deleteButton = new JButton(rb.getString("Button.Delete")); p.add(new JLabel(rb.getString("Label.Account")), cc.xy(1, 1)); p.add(accountCombo, cc.xywh(3, 1, 3, 1)); p.add(new JLabel(rb.getString("Label.Description")), cc.xy(1, 3)); p.add(descriptionField, cc.xywh(3, 3, 3, 1)); p.add(new JLabel(rb.getString("Label.Transaction")), cc.xy(1, 5)); p.add(transactionField, cc.xy(3, 5)); p.add(ButtonBarFactory.buildLeftAlignedBar(editButton, deleteButton), cc.xy(5, 5)); p.add(new JLabel(rb.getString("Label.Notes")), cc.xy(1, 7)); p.add(pane, cc.xywh(3, 7, 3, 1)); return p; }
From source file:jgnash.ui.recurring.WeekTab.java
License:Open Source License
private void layoutMainPanel() { FormLayout layout = new FormLayout("right:p, $lcgap, f:p, 2dlu, max(48dlu;min), $lcgap, f:p, 2dlu, f:d", "f:p, $lgap, f:p, $lgap, f:p"); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); setLayout(layout);//w ww . j a v a 2 s .c o m setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); noEndButton = new JRadioButton(rb.getString("Button.NoEndDate")); endButton = new JRadioButton(); endDateField = new DatePanel(); group.add(noEndButton); group.add(endButton); numberSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 52, 1)); add(new JLabel(rb.getString("Label.Every")), cc.xy(1, 1)); add(numberSpinner, cc.xywh(3, 1, 3, 1)); add(new JLabel(rb.getString("Tab.Week")), cc.xy(7, 1)); add(new JLabel(rb.getString("Label.EndOn")), cc.xy(1, 3)); add(noEndButton, cc.xywh(3, 3, 5, 1)); add(endButton, cc.xy(3, 5)); add(endDateField, cc.xy(5, 5)); }
From source file:jgnash.ui.recurring.YearTab.java
License:Open Source License
private void layoutMainPanel() { FormLayout layout = new FormLayout("right:p, $lcgap, f:p, 2dlu, max(48dlu;min), 2dlu, f:p", "f:p, $lgap, f:p, $lgap, f:p"); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); setLayout(layout);/* www . jav a2 s.c om*/ setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); noEndButton = new JRadioButton(rb.getString("Button.NoEndDate")); endButton = new JRadioButton(); endDateField = new DatePanel(); group.add(noEndButton); group.add(endButton); numberSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 100, 1)); add(new JLabel(rb.getString("Label.Every")), cc.xy(1, 1)); add(numberSpinner, cc.xywh(3, 1, 3, 1)); add(new JLabel(rb.getString("Tab.Year")), cc.xy(7, 1)); add(new JLabel(rb.getString("Label.EndOn")), cc.xy(1, 3)); add(noEndButton, cc.xywh(3, 3, 5, 1)); add(endButton, cc.xy(3, 5)); add(endDateField, cc.xy(5, 5)); }
From source file:jgnash.ui.register.AbstractTransactionEntryPanel.java
License:Open Source License
private void layoutMainPanel() { init();/* w ww.j av a 2 s .co m*/ FormLayout layout = new FormLayout("d, 4dlu, d:g, 8dlu, d, 4dlu, 45dlu", "f:d, $nlgap, f:d, $nlgap, f:d"); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); CellConstraints cc = new CellConstraints(); setLayout(layout); setBorder(Borders.DIALOG_BORDER); add("Label.Account", cc.xy(1, 1)); add(accountPanel, cc.xy(3, 1)); add("Label.Amount", cc.xy(5, 1)); add(amountField, cc.xy(7, 1)); add("Label.Memo", cc.xy(1, 3)); add(memoField, cc.xywh(3, 3, 5, 1)); add(createBottomPanel(), cc.xywh(1, 5, 7, 1)); clearForm(); }
From source file:jgnash.ui.register.AdjustmentPanel.java
License:Open Source License
private void layoutMainPanel() { FormLayout layout = new FormLayout("right:d, $lcgap, 50dlu:g, 8dlu, right:d, $lcgap, max(48dlu;min)", "f:d, $nlgap, f:d, $nlgap, f:d, $nlgap, f:d"); layout.setRowGroups(new int[][] { { 1, 3, 5, 7 } }); CellConstraints cc = new CellConstraints(); setLayout(layout);/*from w ww . j a v a2s .c o m*/ setBorder(Borders.DIALOG_BORDER); add("Label.Payee", cc.xy(1, 1)); add(payeeField, cc.xy(3, 1)); add("Label.Number", cc.xy(5, 1)); add(numberField, cc.xy(7, 1)); add("Label.Memo", cc.xy(1, 3)); add(memoField, cc.xy(3, 3)); add("Label.Date", cc.xy(5, 3)); add(datePanel, cc.xy(7, 3)); add(reconciledButton, cc.xywh(1, 5, 3, 1)); add("Label.Amount", cc.xy(5, 5)); add(ValidationFactory.wrap(amountField), cc.xy(7, 5)); add(ButtonBarFactory.buildHelpBar(convertButton, enterButton, cancelButton), cc.xywh(1, 7, 7, 1)); }
From source file:jgnash.ui.register.DateChkNumberDialog.java
License:Open Source License
private void buildPanel() { initComponents();/*from w w w. ja v a 2 s . com*/ FormLayout layout = new FormLayout("max(20dlu;d), 4dlu, 75dlu:grow(1.0)", "f:d, 3dlu, f:d, 10dlu, f:d"); CellConstraints cc = new CellConstraints(); layout.setRowGroups(new int[][] { { 1, 3, 5 } }); JPanel p = new JPanel(layout); p.setBorder(Borders.DIALOG_BORDER); p.add(new JLabel(rb.getString("Label.Date")), cc.xy(1, 1)); p.add(datePanel, cc.xy(3, 1)); p.add(new JLabel(rb.getString("Label.Number")), cc.xy(1, 3)); p.add(numberCombo, cc.xy(3, 3)); p.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), cc.xyw(1, 5, 3)); getContentPane().add(p, BorderLayout.CENTER); }