List of usage examples for com.jgoodies.forms.builder ButtonStackBuilder addUnrelatedGap
@Override
public ButtonStackBuilder addUnrelatedGap()
From source file:ai.aitia.meme.utils.FormsUtils.java
License:Open Source License
/** * Example:<pre>/*from w w w .j a v a2s . co m*/ * buttonStack( jMoveUpButton, jMoveDownButton, FormsUtils.BS_UNRELATED, * jRemoveButton, jEditButton ).getPanel() * </pre> */ public static ButtonStackBuilder buttonStack(Object... args) { ButtonStackBuilder ans = new ButtonStackBuilder(); boolean addrel = false; for (int i = 0; i < args.length; ++i) { if (args[i] instanceof javax.swing.JComponent) { if (addrel) ans.addRelatedGap(); ans.addGridded((javax.swing.JComponent) args[i]); addrel = true; } else if (BS_UNRELATED.equals(args[i])) { ans.addUnrelatedGap(); addrel = false; } else if (BS_GLUE.equals(args[i])) { ans.addGlue(); addrel = false; } else { ans.addStrut(Sizes.constant(args[i].toString(), false)); addrel = false; } } return ans; }
From source file:ca.sqlpower.architect.swingui.olap.OLAPSchemaManager.java
License:Open Source License
private JPanel createPanel() { FormLayout layout = new FormLayout("6dlu, fill:min(160dlu;default):grow, 6dlu, pref, 6dlu", // columns //$NON-NLS-1$ " 6dlu,10dlu,6dlu,fill:min(180dlu;default):grow,10dlu"); // rows //$NON-NLS-1$ layout.setColumnGroups(new int[][] { { 1, 3, 5 } }); CellConstraints cc = new CellConstraints(); PanelBuilder pb;/* w ww. j av a2s .c o m*/ JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); pb.setDefaultDialogBorder(); pb.add(new JLabel("Available OLAP Schemas"), cc.xy(2, 2)); //$NON-NLS-1$ TableModel tm = new SchemaTableModel(session.getOLAPRootObject()); osessionTable = new JTable(tm); osessionTable.setTableHeader(null); osessionTable.setShowGrid(false); osessionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); osessionTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { boolean enableActions = getSelectedOSession() != null; removeOLAPSchemaAction.setEnabled(enableActions); editOLAPSchemaAction.setEnabled(enableActions); exportSchemaAction.setEnabled(enableActions); if (evt.getClickCount() == 2) { editOLAPSchemaAction.actionPerformed(null); } } }); JScrollPane sp = new JScrollPane(osessionTable); pb.add(sp, cc.xy(2, 4)); ButtonStackBuilder bsb = new ButtonStackBuilder(); JButton newOLAPSchemaButton = new JButton(new OLAPEditAction(session, null)); newOLAPSchemaButton.setText("New..."); bsb.addGridded(newOLAPSchemaButton); bsb.addRelatedGap(); JButton importOLAPSchemaButton = new JButton(new ImportSchemaAction(session)); importOLAPSchemaButton.setText("Import..."); bsb.addGridded(importOLAPSchemaButton); bsb.addGridded(new JButton(exportSchemaAction)); bsb.addRelatedGap(); bsb.addGridded(new JButton(editOLAPSchemaAction)); bsb.addRelatedGap(); bsb.addGridded(new JButton(removeOLAPSchemaAction)); removeOLAPSchemaAction.setEnabled(false); editOLAPSchemaAction.setEnabled(false); exportSchemaAction.setEnabled(false); bsb.addUnrelatedGap(); bsb.addGridded(new JButton(closeAction)); pb.add(bsb.getPanel(), cc.xy(4, 4)); return pb.getPanel(); }
From source file:ca.sqlpower.swingui.db.DatabaseConnectionManager.java
License:Open Source License
private JPanel createPanel(List<Action> additionalActions, List<JComponent> additionalComponents, boolean showCloseButton, String message) { FormLayout layout = new FormLayout("6dlu, fill:min(160dlu;default):grow, 6dlu, pref, 6dlu", // columns //$NON-NLS-1$ " 6dlu,10dlu,6dlu,fill:min(180dlu;default):grow,10dlu"); // rows //$NON-NLS-1$ layout.setColumnGroups(new int[][] { { 1, 3, 5 } }); CellConstraints cc = new CellConstraints(); PanelBuilder pb;/*from ww w. j a va 2s.c o m*/ JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout); pb = new PanelBuilder(layout, p); pb.setDefaultDialogBorder(); pb.add(new JLabel(message), cc.xyw(2, 2, 3)); //$NON-NLS-1$ TableModel tm = new ConnectionTableModel(dsCollection); dsTable = new EditableJTable(tm); dsTable.setTableHeader(null); dsTable.setShowGrid(false); dsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dsTable.addMouseListener(new DSTableMouseListener()); dsTable.setDefaultRenderer(SPDataSource.class, new ConnectionTableCellRenderer()); JScrollPane sp = new JScrollPane(dsTable); sp.getViewport().setBackground(dsTable.getBackground()); pb.add(sp, cc.xy(2, 4)); ButtonStackBuilder bsb = new ButtonStackBuilder(); JButton newButton = new JButton(); AbstractAction newDatabaseConnectionAction = new NewConnectionAction( Messages.getString("DatabaseConnectionManager.newDbConnectionActionName"), newButton); //$NON-NLS-1$ newButton.setAction(newDatabaseConnectionAction); bsb.addGridded(newButton); bsb.addRelatedGap(); bsb.addGridded(new JButton(editDatabaseConnectionAction)); bsb.addRelatedGap(); bsb.addGridded(new JButton(removeDatabaseConnectionAction)); removeDatabaseConnectionAction.setEnabled(false); editDatabaseConnectionAction.setEnabled(false); bsb.addUnrelatedGap(); JButton jdbcDriversButton = new JButton(jdbcDriversAction); bsb.addGridded(jdbcDriversButton); for (Action a : additionalActions) { bsb.addUnrelatedGap(); JButton b = new JButton(a); Object disableValue = a.getValue(DISABLE_IF_NO_CONNECTION_SELECTED); if (disableValue instanceof Boolean && disableValue.equals(Boolean.TRUE)) { b.setEnabled(false); } Object heightValue = a.getValue(ADDITIONAL_BUTTON_HEIGHT); if (heightValue instanceof Integer) { b.setPreferredSize(new Dimension((int) b.getPreferredSize().getWidth(), (Integer) heightValue)); } Object verticalTextPos = a.getValue(VERTICAL_TEXT_POSITION); if (verticalTextPos instanceof Integer) { Integer verticalTextInt = (Integer) verticalTextPos; if (verticalTextInt == SwingConstants.TOP || verticalTextInt == SwingConstants.BOTTOM || verticalTextInt == SwingConstants.CENTER) { b.setVerticalTextPosition(verticalTextInt); } } Object horizontalTextPos = a.getValue(HORIZONTAL_TEXT_POSITION); if (horizontalTextPos instanceof Integer) { Integer horizontalTextInt = (Integer) horizontalTextPos; if (horizontalTextInt == SwingConstants.LEFT || horizontalTextInt == SwingConstants.RIGHT || horizontalTextInt == SwingConstants.CENTER || horizontalTextInt == SwingConstants.LEADING || horizontalTextInt == SwingConstants.TRAILING) { b.setHorizontalTextPosition(horizontalTextInt); } } additionalActionButtons.add(b); bsb.addFixed(b); } for (JComponent comp : additionalComponents) { bsb.addUnrelatedGap(); bsb.addFixed(comp); } if (showCloseButton) { bsb.addUnrelatedGap(); bsb.addGridded(new JButton(closeAction)); } pb.add(bsb.getPanel(), cc.xy(4, 4)); return pb.getPanel(); }
From source file:jgnash.ui.budget.BudgetManagerDialog.java
License:Open Source License
private void layoutMainPanel() { initComponents();//www .java2 s . c om // build the button stack ButtonStackBuilder buttonStackBuilder = new ButtonStackBuilder(); buttonStackBuilder.addButton(newAutoButton, newButton, duplicateButton, renameButton); buttonStackBuilder.addUnrelatedGap(); buttonStackBuilder.addButton(deleteButton); FormLayout layout = new FormLayout("p:g, $lcgap, f:p", "f:max(35dlu;p):g, $ugap, p"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.add(new JScrollPane(budgetList), cc.xy(1, 1)); builder.add(buttonStackBuilder.getPanel(), cc.xy(3, 1)); builder.add(ButtonBarFactory.buildCloseBar(closeButton), cc.xyw(1, 3, 3)); getContentPane().add(builder.getPanel(), BorderLayout.CENTER); pack(); setMinimumSize(getSize()); }
From source file:loci.visbio.view.CapturePanel.java
License:Open Source License
/** Constructs a window for capturing display screenshots and movies. */ public CapturePanel(final CaptureHandler h) { super();/*from ww w . j a v a 2s. c om*/ handler = h; // positions list posListModel = new DefaultListModel(); posList = new JList(posListModel); posList.setFixedCellWidth(120); posList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); posList.addListSelectionListener(this); posList.setToolTipText("List of captured display positions"); // add button final JButton add = new JButton("Add"); add.setActionCommand("Add"); add.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) add.setMnemonic('a'); add.setToolTipText("Adds the current display position to the list"); // remove button remove = new JButton("Remove"); remove.setActionCommand("Remove"); remove.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) remove.setMnemonic('r'); remove.setToolTipText("Removes the selected position from the list"); remove.setEnabled(false); // up button moveUp = new JButton("Up"); moveUp.setActionCommand("Up"); moveUp.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) moveUp.setMnemonic('u'); moveUp.setToolTipText("Moves the selected position up in the list"); moveUp.setEnabled(false); // down button moveDown = new JButton("Down"); moveDown.setActionCommand("Down"); moveDown.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) moveDown.setMnemonic('d'); moveDown.setToolTipText("Moves the selected position down in the list"); moveDown.setEnabled(false); // snapshot button final JButton snapshot = new JButton("Snapshot"); snapshot.setActionCommand("Snapshot"); snapshot.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) snapshot.setMnemonic('n'); snapshot.setToolTipText("Saves display snapshot to an image file"); // send to ImageJ button final JButton sendToImageJ = new JButton("Send to ImageJ"); sendToImageJ.setActionCommand("SendImageJ"); sendToImageJ.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) sendToImageJ.setMnemonic('j'); sendToImageJ.setToolTipText("Sends display snapshot to ImageJ program"); // speed slider speed = new JSlider(0, 16, 8); speed.setAlignmentY(Component.TOP_ALIGNMENT); speed.setMajorTickSpacing(4); speed.setMinorTickSpacing(1); final Hashtable speedHash = new Hashtable(); speedHash.put(new Integer(0), new JLabel("4 (slow)")); speedHash.put(new Integer(4), new JLabel("2")); speedHash.put(new Integer(8), new JLabel("1")); speedHash.put(new Integer(12), new JLabel("1/2")); speedHash.put(new Integer(16), new JLabel("1/4 (fast)")); speed.setLabelTable(speedHash); speed.setSnapToTicks(true); speed.setPaintTicks(true); speed.setPaintLabels(true); speed.addChangeListener(this); speed.setToolTipText("Adjusts seconds per transition"); // frames per second spinner fps = new JSpinner(new SpinnerNumberModel(10, 1, 600, 1)); fps.addChangeListener(this); fps.setToolTipText("Adjusts output movie's frames per second"); // smoothness checkbox smooth = new JCheckBox("Emphasize transition at each display position", true); smooth.addItemListener(this); if (!LAFUtil.isMacLookAndFeel()) smooth.setMnemonic('e'); smooth.setToolTipText("Use smooth sine function transitions"); // record button final JButton record = new JButton("Record >"); record.setActionCommand("Record"); record.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) record.setMnemonic('r'); record.setToolTipText("Records a movie of transitions between display positions"); // progress bar progress = new JProgressBar(0, 100); progress.setString(""); progress.setStringPainted(true); progress.setToolTipText("Displays movie recording progress"); // lay out buttons final ButtonStackBuilder bsb = new ButtonStackBuilder(); bsb.addGridded(add); bsb.addRelatedGap(); bsb.addGridded(remove); bsb.addUnrelatedGap(); bsb.addGridded(moveUp); bsb.addRelatedGap(); bsb.addGridded(moveDown); final JPanel buttons = bsb.getPanel(); // lay out position list final PanelBuilder positionList = new PanelBuilder( new FormLayout("default:grow, 3dlu, pref", "fill:pref:grow")); final CellConstraints cc = new CellConstraints(); final JScrollPane posScroll = new JScrollPane(posList); SwingUtil.configureScrollPane(posScroll); positionList.add(posScroll, cc.xy(1, 1)); positionList.add(buttons, cc.xy(3, 1)); // lay out transition speed slider final PanelBuilder transitionSpeed = new PanelBuilder( new FormLayout("pref, 3dlu, pref, 3dlu, pref:grow, 3dlu, pref", "pref")); final JLabel speedLabel = transitionSpeed.addLabel("&Seconds per transition", cc.xy(1, 1)); speedLabel.setLabelFor(speed); transitionSpeed.add(speed, cc.xy(5, 1)); // lay out movie recording button and progress bar final PanelBuilder movieRecord = new PanelBuilder(new FormLayout("pref, 3dlu, pref:grow", "pref")); movieRecord.add(record, cc.xy(1, 1)); movieRecord.add(progress, cc.xy(3, 1)); // lay out components final JPanel pane = FormsUtil.makeColumn(new Object[] { "Display positions", positionList.getPanel(), "Screenshots", FormsUtil.makeRow(snapshot, sendToImageJ), "Movies", FormsUtil.makeRow("&Frames per second", fps), transitionSpeed.getPanel(), smooth, movieRecord.getPanel() }, "pref:grow", false); setLayout(new BorderLayout()); add(pane); }
From source file:loci.visbio.view.DisplayControls.java
License:Open Source License
/** Constructs a tool panel for adjusting data parameters. */ public DisplayControls(final LogicManager logic) { super(logic, "Displays", "Controls for managing displays"); // list of displays listModel = new DefaultListModel(); displayList = new JList(listModel); displayList.setFixedCellWidth(250);/*from w w w .ja va 2 s . com*/ displayList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); displayList.addListSelectionListener(this); final JScrollPane listPane = new JScrollPane(displayList); SwingUtil.configureScrollPane(listPane); // add 2D button add2D = new JButton("Add 2D..."); add2D.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) add2D.setMnemonic('2'); add2D.setToolTipText("Creates a new 2D display"); // add 3D button add3D = new JButton("Add 3D..."); add3D.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) add3D.setMnemonic('3'); add3D.setToolTipText("Creates a new 3D display"); add3D.setEnabled(DisplayUtil.canDo3D()); // show button show = new JButton("Show"); show.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) show.setMnemonic('s'); show.setToolTipText("Displays the selected display onscreen"); show.setEnabled(false); // remove data button remove = new JButton("Remove"); remove.addActionListener(this); if (!LAFUtil.isMacLookAndFeel()) remove.setMnemonic('m'); remove.setToolTipText("Deletes the selected display"); remove.setEnabled(false); // lay out buttons final ButtonStackBuilder bsb = new ButtonStackBuilder(); bsb.addGridded(add2D); bsb.addRelatedGap(); bsb.addGridded(add3D); bsb.addUnrelatedGap(); bsb.addGridded(show); bsb.addRelatedGap(); bsb.addGridded(remove); final JPanel buttons = bsb.getPanel(); // lay out components final PanelBuilder builder = new PanelBuilder(new FormLayout("pref:grow, 3dlu, pref", "pref")); final CellConstraints cc = new CellConstraints(); builder.add(listPane, cc.xy(1, 1)); builder.add(buttons, cc.xy(3, 1)); add(builder.getPanel()); }
From source file:org.columba.mail.gui.config.folder.FolderOptionsDialog.java
License:Mozilla Public License
/** * Create advanced panel.// w ww. j av a 2s .com * <p> * * @return panel */ protected JPanel createAdvancedPanel() { // Create a FormLayout instance. FormLayout layout = new FormLayout("fill:default:grow, 6px, default", //$NON-NLS-1$ // 3 columns "pref, 6px, fill:pref:grow"); //$NON-NLS-1$ // create a form builder PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); // create EmptyBorder between components and dialog-frame builder.setDefaultDialogBorder(); builder.add(overwriteLabel, cc.xywh(1, 1, 3, 1)); JScrollPane sp = new JScrollPane(checkableList); sp.setPreferredSize(new Dimension(200, 200)); sp.getViewport().setBackground(Color.white); builder.add(sp, cc.xy(1, 3)); ButtonStackBuilder b = new ButtonStackBuilder(); b.addGridded(enableButton); b.addRelatedGap(); b.addGridded(disableButton); b.addUnrelatedGap(); b.addGlue(); b.addFixed(resetButton); JPanel buttonPanel = b.getPanel(); builder.add(buttonPanel, cc.xy(3, 3)); /* * JPanel panel= new JPanel(); panel.setLayout(new BorderLayout()); * panel.add(resetButton, BorderLayout.EAST); builder.add(panel, * cc.xywh(5, 7, 1, 1)); */ /* * builder.addSeparator("Full-text indexing"); * * builder.add(enableLabel, cc.xywh(1, 7, 5, 1)); * builder.add(enableTextIndexingCheckBox, cc.xywh(2, 9, 4, 1)); */ return builder.getPanel(); }
From source file:org.pathvisio.visualization.plugins.SortSampleCheckList.java
License:Apache License
public SortSampleCheckList(List<? extends ISample> selected, GexManager gexManager) { checkList = new SampleCheckList(selected, gexManager); setLayout(new FormLayout("fill:pref:grow, 2dlu, pref", "fill:pref:grow")); CellConstraints cc = new CellConstraints(); add(new JScrollPane(checkList), cc.xy(1, 1)); JButton top = new JButton(); top.setActionCommand(ACTION_TOP);/*from w ww . ja v a2 s .c o m*/ top.addActionListener(this); top.setIcon(new ImageIcon(ICON_TOP)); top.setHorizontalTextPosition(SwingConstants.CENTER); JButton up = new JButton(); up.setActionCommand(ACTION_UP); up.addActionListener(this); up.setIcon(new ImageIcon(ICON_UP)); up.setHorizontalTextPosition(SwingConstants.CENTER); JButton down = new JButton(); down.setActionCommand(ACTION_DOWN); down.addActionListener(this); down.setIcon(new ImageIcon(ICON_DOWN)); down.setHorizontalTextPosition(SwingConstants.CENTER); JButton bottom = new JButton(); bottom.setActionCommand(ACTION_BOTTOM); bottom.addActionListener(this); bottom.setIcon(new ImageIcon(ICON_BOTTOM)); bottom.setHorizontalTextPosition(SwingConstants.CENTER); JPanel btnPanel = new JPanel(); ButtonStackBuilder builder = new ButtonStackBuilder(new FormLayout("28px"), btnPanel); builder.addGridded(top); builder.addUnrelatedGap(); builder.addGridded(up); builder.addRelatedGap(); builder.addGridded(down); builder.addRelatedGap(); builder.addGridded(bottom); add(btnPanel, cc.xy(3, 1, "c, c")); }