Example usage for javax.swing Box add

List of usage examples for javax.swing Box add

Introduction

In this page you can find the example usage for javax.swing Box add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:org.jdal.swing.TableEditor.java

/**
 * {@inheritDoc}/*from ww  w.j  av  a  2  s. c  o m*/
 */
@Override
protected JComponent buildPanel() {
    Box box = Box.createVerticalBox();
    Container tablePanel = createTablePanel();
    box.add(tablePanel);
    box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    return box;
}

From source file:geovista.network.gui.ClusteringDemo.java

private void setUpView() throws IOException {

    /*/*ww  w  .  j  a  va 2  s. c o  m*/
     * Factory<Integer> vertexFactory = new Factory<Integer>() { int n = 0;
     * public Integer create() { return n++; } }; Factory<Number>
     * edgeFactory = new Factory<Number>() { int n = 0; public Number
     * create() { return n++; } };
     */

    /*
     * PajekNetReader<Graph<Integer, Number>, Integer,Number> pnr = new
     * PajekNetReader<Graph<Integer, Number>, Integer,Number>(vertexFactory,
     * edgeFactory);
     * 
     * final Graph<Integer,Number> graph = new SparseMultigraph<Integer,
     * Number>();
     * 
     * pnr.load(br, graph);
     */

    // Create a simple layout frame
    // specify the Fruchterman-Rheingold layout algorithm
    layout = new AggregateLayout<Integer, Number>(new FRLayout<Integer, Number>(g));

    vv = new VisualizationViewer<Integer, Number>(layout);
    vv.setBackground(Color.white);
    // Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() {
        public Paint transform(Integer v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.blue;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY) {
                return THIN;
            } else {
                return THICK;
            }
        }
    });

    /*
     * //add restart button JButton scramble = new JButton("Restart");
     * scramble.addActionListener(new ActionListener() { public void
     * actionPerformed(ActionEvent arg0) { Layout layout =
     * vv.getGraphLayout(); layout.initialize(); Relaxer relaxer =
     * vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop();
     * relaxer.prerelax(); relaxer.relax(); } }
     * 
     * });
     * 
     * DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
     * vv.setGraphMouse(gm);
     */

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    // Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(g.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    // TO DO: edgeBetweennessSlider.add(new
    // JLabel("Node Size (PageRank With Priors):"));
    // I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    /*
     * eastControls.setOpaque(true); eastControls.setLayout(new
     * BoxLayout(eastControls, BoxLayout.Y_AXIS));
     * eastControls.add(Box.createVerticalGlue());
     */
    // eastControls.add(edgeBetweennessSlider);

    final Box cluster_panel = Box.createVerticalBox();
    cluster_panel.setBorder(BorderFactory.createTitledBorder("Cluster"));
    cluster_panel.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    /*
     * eastControls.setBorder(sliderBorder); //eastControls.add(eastSize);
     * eastControls.add(Box.createVerticalGlue());
     */

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    cluster_panel.add(groupVertices);
    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    // grid.add(scramble);
    grid.add(cluster_panel);
    // south.add
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    // p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    // p.add(gm.getModeComboBox());
    south.add(p);

    content.add(south, BorderLayout.SOUTH);
}

From source file:pcgen.gui2.tabs.spells.SpellsPreparedTab.java

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override//  w w  w .  ja  v  a  2  s  . com
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }

    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter")); //$NON-NLS-1$
    filterBar.addDisplayableFilter(qFilterButton);

    FlippingSplitPane upperPane = new FlippingSplitPane("SpellsPreparedTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        addMMSpellButton.setHorizontalTextPosition(SwingConstants.LEADING);
        hbox.add(addMMSpellButton);
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(2));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(slotsBox);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(addSpellButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);

    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(4));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeSpellButton);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel(LanguageBundle.getString("InfoPreparedSpells.preparedList")));
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(spellListField);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(addSpellListButton);
        hbox.add(Box.createHorizontalStrut(3));
        hbox.add(removeSpellListButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);

    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellsPreparedBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}

From source file:psidev.psi.mi.filemakers.xmlMaker.XmlMakerGui.java

public XmlMakerGui() {
    super("XML Maker");

    /* look n'feel */
    try {//  w ww .  ja  v a2  s. c  om
        //         UIManager.setLookAndFeel(new TonicLookAndFeel());
    } catch (Exception e) {
        System.out.println("Unable to load look'n feel");
    }

    getContentPane().setLayout(new BorderLayout());

    xsdTree = new XsdTreeStructImpl();
    JTextPaneMessageManager messageManager = new JTextPaneMessageManager();
    xsdTree.setMessageManager(messageManager);
    treePanel = new XsdTreePanelImpl(xsdTree, messageManager);

    flatFileTabbedPanel = new FlatFileTabbedPanel(xsdTree.flatFiles);
    flatFileTabbedPanel.setBorder(new TitledBorder("Flat files"));

    dictionnaryLists = new DictionaryPanel(xsdTree.dictionaries);
    dictionnaryLists.setBorder(new TitledBorder("Dictionnary"));

    Box associationsPanels = new Box(BoxLayout.Y_AXIS);

    associationsPanels.add(flatFileTabbedPanel);

    associationsPanels.add(dictionnaryLists);
    getContentPane().add(associationsPanels, BorderLayout.WEST);

    getContentPane().add(treePanel, BorderLayout.CENTER);

    treePanel.setTabFileTabbedPanel(flatFileTabbedPanel);
    treePanel.setDictionnaryPanel(dictionnaryLists);
    final CloseView fv = new CloseView();
    addWindowListener(fv);
    setJMenuBar(new XmlMakerMenu());
    //      setSize(800, 600);
    this.pack();
    setVisible(true);

    if (mappingFileName != null) {
        load(new File(mappingFileName));
    }

}

From source file:com.diversityarrays.dal.server.SqlDialog.java

SqlDialog(JFrame owner, SqlDalDatabase db) {
    super(owner, "SQL", ModalityType.MODELESS);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.database = db;

    runner = new DefaultBackgroundRunner("SQL Command", this);
    setGlassPane(runner.getBlockingPane());

    sqlCommands.setFont(GuiUtil.createMonospacedFont(12));

    includeHeadingsInCopy.addItemListener(new ItemListener() {
        @Override//from  w ww  .j  a v a2 s  .c o  m
        public void itemStateChanged(ItemEvent e) {
            boolean b = includeHeadingsInCopy.isSelected();
            for (int n = tabbedPane.getTabCount(); --n >= 0;) {
                Component c = tabbedPane.getComponentAt(n);
                if (c instanceof SqlResultsPanel) {
                    ((SqlResultsPanel) c).setIncludeHeadings(b);
                }
            }
        }
    });

    tabbedPane.addContainerListener(new ContainerListener() {
        @Override
        public void componentRemoved(ContainerEvent e) {
            updateClosePanelAction();
        }

        @Override
        public void componentAdded(ContainerEvent e) {
            updateClosePanelAction();
        }
    });
    updateClosePanelAction();

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(runAction));
    buttons.add(Box.createHorizontalStrut(20));
    buttons.add(new JButton(closePanelAction));

    buttons.add(Box.createHorizontalGlue());
    buttons.add(includeHeadingsInCopy);
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(helpAction));
    buttons.add(Box.createHorizontalStrut(10));

    JPanel top = new JPanel(new BorderLayout());
    top.add(BorderLayout.CENTER, new JScrollPane(sqlCommands));
    top.add(BorderLayout.SOUTH, buttons);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, tabbedPane);
    splitPane.setResizeWeight(0.25);

    setContentPane(splitPane);

    pack();

    setSize(800, 600);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            splitPane.setDividerLocation(0.25);
            removeWindowListener(this);
        }

    });
}

From source file:org.jcurl.demo.tactics.TacticsApp.java

public TacticsApp() {
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            TacticsApp.this.cmdExit();
        }/* w w  w.  j a va  2  s  .c om*/
    });
    master = new RockEditDisplay();
    master.setPos(mod_locations);
    master.setSpeed(mod_speeds);
    final PositionDisplay pnl2 = new PositionDisplay();
    pnl2.setPos(mod_locations);
    pnl2.setZoom(Zoomer.HOG2HACK);

    final Container con = getContentPane();
    {
        final JPanel p = new JPanel(new BorderLayout());
        p.add(new SumWaitDisplay(mod_locations), "West");
        p.add(master, "Center");
        p.add(new SumShotDisplay(mod_locations), "East");
        con.add(p, "Center");
    }
    // con.add(new SumWaitDisplay(mod_locations), "West");
    con.add(new SumOutDisplay(mod_locations), "West");
    {
        final Box b1 = Box.createHorizontalBox();
        b1.add(Box.createRigidArea(new Dimension(0, 75)));
        b1.add(pnl2);
        con.add(b1, "South");
    }
    final JTabbedPane t = new JTabbedPane();
    con.add(t, "East");
    {
        final Box b0 = Box.createHorizontalBox();
        t.add("Rock", b0);
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            final Box b2 = Box.createVerticalBox();
            b2.add(new JComboBox(new String[] { "Dark", "Light" }));
            b2.add(new JLabel("Broom", SwingConstants.LEFT));
            b1.add(b2, "North");
            JSlider s = new JSlider(-2000, 2000, 0);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final Box b3 = Box.createHorizontalBox();
            b3.add(new JFormattedTextField());
            b3.add(new JLabel("mm", SwingConstants.LEFT));
            b1.add(b3, "South");
            b0.add(b1);
        }
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            final Box b2 = Box.createVerticalBox();
            b2.add(new JComboBox(new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }));
            b2.add(new JLabel("Splittime", SwingConstants.LEFT));
            b1.add(b2, "North");
            JSlider s = new JSlider(500, 2500, 1500);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final Box b3 = Box.createHorizontalBox();
            b3.add(new JSpinner());
            b3.add(new JLabel("ms", SwingConstants.LEFT));
            b1.add(b3, "South");
            b0.add(b1);
        }
    }
    {
        final Box b0 = Box.createHorizontalBox();
        t.add("Ice", b0);
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            b1.add(new JLabel("Curl"), "North");
            JSlider s = new JSlider(0, 5000, 0);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final JSpinner s1 = new JSpinner();
            b1.add(s1, "South");
            b0.add(b1);
        }
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            b1.add(new JLabel("DrawToTee"), "North");
            JSlider s = new JSlider(15000, 30000, 25000);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(5000);
            s.setMinorTickSpacing(1000);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final JSpinner s1 = new JSpinner();
            b1.add(s1, "South");
            b0.add(b1);
        }
    }
    setJMenuBar(createMenu());
    refreshTitle();
    this.setSize(900, 400);

    new SpeedController(mod_locations, mod_speeds, master);
    new LocationController(mod_locations, pnl2);
    lastSaved = mod_locations.getLastChanged();
}

From source file:pcgen.gui2.dialog.PrintPreviewDialog.java

private void initLayout() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    {//layout top bar
        JPanel bar = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.BASELINE;
        gbc.insets = new Insets(8, 6, 8, 2);
        bar.add(new JLabel("Select Template:"), gbc);
        gbc.insets = new Insets(8, 2, 8, 6);
        gbc.weightx = 1;// w  w  w.  ja  v a 2  s.  c o  m
        bar.add(sheetBox, gbc);
        pane.add(bar, BorderLayout.NORTH);
    }
    {
        Box vbox = Box.createVerticalBox();
        previewPanelParent.setPreferredSize(new Dimension(600, 800));
        vbox.add(previewPanelParent);
        vbox.add(progressBar);
        pane.add(vbox, BorderLayout.CENTER);
    }
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(new JLabel("Page:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(pageBox);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel("Zoom:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(zoomBox);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomInButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomOutButton);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(printButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(cancelButton);
        hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
        pane.add(hbox, BorderLayout.SOUTH);
    }
}

From source file:com.diversityarrays.kdxplore.trials.TrialDetailsPanel.java

TrialDetailsPanel(WindowOpener<JFrame> windowOpener, MessagePrinter mp, BackgroundRunner backgroundRunner,
        OfflineData offlineData, Action editTrialAction, Action seedPrepAction, Action harvestAction,
        Action uploadTrialAction, Action refreshTrialInfoAction, ImageIcon barcodeIcon,
        Transformer<Trial, Boolean> checkIfEditorActive, Consumer<Trial> onTraitInstancesRemoved) {
    super(new BorderLayout());

    this.editTrialAction = editTrialAction;
    this.uploadTrialAction = uploadTrialAction;
    this.refreshTrialInfoAction = refreshTrialInfoAction;
    this.onTraitInstancesRemoved = onTraitInstancesRemoved;

    this.messagePrinter = mp;
    this.backgroundRunner = backgroundRunner;
    this.offlineData = offlineData;

    if (barcodeIcon == null) {
        barcodesMenuButton = new JLabel("Barcodes"); //$NON-NLS-1$
    } else {/*w w  w  .  ja  v a 2  s . co m*/
        barcodesMenuButton = new JLabel(barcodeIcon);
    }
    barcodesMenuButton.setBorder(BorderFactory.createRaisedSoftBevelBorder());

    barcodesMenuButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (trial != null) {
                barcodesMenuHandler.handleMouseClick(e.getPoint());
            }
        }
    });

    trialViewPanel = new TrialViewPanel(windowOpener, offlineData, checkIfEditorActive, onTraitInstancesRemoved,
            mp);

    Box buttons = Box.createHorizontalBox();
    buttons.add(new JButton(refreshTrialInfoAction));
    buttons.add(new JButton(seedPrepAction));
    buttons.add(new JButton(editTrialAction));
    buttons.add(new JButton(uploadTrialAction));
    buttons.add(new JButton(harvestAction));
    buttons.add(barcodesMenuButton);
    buttons.add(Box.createHorizontalGlue());

    //      JPanel trialPanel = new JPanel(new BorderLayout());
    //      trialPanel.add(buttons, BorderLayout.NORTH);
    //      trialPanel.add(fieldViewPanel, BorderLayout.CENTER);

    cardPanel.add(new JLabel(Msg.LABEL_NO_TRIAL_SELECTED()), CARD_NO_TRIAL);
    cardPanel.add(trialViewPanel, CARD_HAVE_TRIAL);

    setSelectedTrial(null);

    add(buttons, BorderLayout.NORTH);
    add(cardPanel, BorderLayout.CENTER);
}

From source file:pcgen.gui2.tabs.bio.CampaignHistoryInfoPane.java

private void initComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    addButton.setText("Add Next Chronicle");
    addButton.setActionCommand(ADD_COMMAND);
    allButton.setText("All");
    allButton.setActionCommand(ALL_COMMAND);
    noneButton.setText("None");
    noneButton.setActionCommand(NONE_COMMAND);

    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(new JLabel("Check an item to include on your Character Sheet"));
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(allButton);//from   w  w  w.  ja  v a2 s. c om
    hbox.add(Box.createRigidArea(new Dimension(3, 0)));
    hbox.add(noneButton);
    hbox.add(Box.createHorizontalGlue());

    add(Box.createVerticalStrut(5));
    add(hbox);
    add(Box.createVerticalStrut(10));
    JScrollPane pane = new JScrollPane(chroniclesPane) {

        @Override
        public Dimension getMaximumSize() {
            Dimension size = getPreferredSize();
            size.width = Integer.MAX_VALUE;
            return size;
        }

        @Override
        public boolean isValidateRoot() {
            return false;
        }

    };
    pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    add(pane);
    add(Box.createVerticalStrut(10));
    addButton.setAlignmentX(0.5f);
    add(addButton);
    add(Box.createVerticalStrut(5));
    add(Box.createVerticalGlue());
}

From source file:com.diversityarrays.kdxplore.trialdesign.RscriptFinderPanel.java

public RscriptFinderPanel(BackgroundRunner br, Component component, String initialScriptPath,
        Consumer<Either<Throwable, String>> onScriptPathChecked) {
    super(new BorderLayout());

    backgroundRunner = br;//from ww w.  ja  v  a 2  s .c om
    this.onScriptPathChecked = onScriptPathChecked;

    scriptPathField.setText(initialScriptPath);
    scriptPathField.addMouseListener(clickAdapter);

    Box scriptPathBox = Box.createHorizontalBox();

    Consumer<Void> updateFindScriptButton = new Consumer<Void>() {
        @Override
        public void accept(Void t) {
            checkScriptPath.setEnabled(!scriptPathField.getText().trim().isEmpty());
        }
    };

    scriptPathBox.add(scriptPathField);
    scriptPathBox.add(new JButton(checkScriptPath));
    scriptPathField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            updateFindScriptButton.accept(null);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateFindScriptButton.accept(null);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateFindScriptButton.accept(null);
        }
    });
    updateFindScriptButton.accept(null);

    add(scriptPathBox, BorderLayout.NORTH);
    if (component != null) {
        add(component, BorderLayout.CENTER);
    }
}