Example usage for javax.swing BoxLayout BoxLayout

List of usage examples for javax.swing BoxLayout BoxLayout

Introduction

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

Prototype

@ConstructorProperties({ "target", "axis" })
public BoxLayout(Container target, int axis) 

Source Link

Document

Creates a layout manager that will lay out components along the given axis.

Usage

From source file:com.idealista.solrmeter.view.statistic.OperationTimeLineChartPanel.java

private Component createCheckBoxPanel() {
    JPanel panelCheckBox = new JPanel();
    panelCheckBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panelCheckBox.setLayout(new BoxLayout(panelCheckBox, BoxLayout.X_AXIS));
    checkBoxShowCommit = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.commit"));
    checkBoxShowCommit.addActionListener(this);
    checkBoxShowOptimize = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.optimize"));
    checkBoxShowOptimize.addActionListener(this);
    checkBoxShowAdd = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.add"));
    checkBoxShowAdd.addActionListener(this);
    checkBoxShowQueries = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.query"));
    checkBoxShowQueries.addActionListener(this);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowCommit);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowOptimize);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowQueries);
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.add(checkBoxShowAdd);//from  ww  w .j a va  2  s .  co  m
    panelCheckBox.add(Box.createHorizontalGlue());
    panelCheckBox.setMaximumSize(new Dimension(800, 25));
    checkAll();
    return panelCheckBox;
}

From source file:be.ac.ua.comp.scarletnebula.gui.TaggingPanel.java

public TaggingPanel(final Collection<String> initialTags) {
    super(new BorderLayout());

    for (final String tag : initialTags) {
        taglist.addTag(new TagItem(tag));
    }/*from   w ww.j a  v  a2s.  c o  m*/
    final BetterTextField inputField = new BetterTextField();
    addTagActionListener = new AddTagActionListener(inputField);
    inputField.addActionListener(addTagActionListener);
    final String hint = "Type a tag and press enter";
    inputField.setPlaceHolder(hint);
    inputField.setToolTipText(hint);
    inputField.setInputVerifier(new TagInputVerifier(inputField));
    inputField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0),
            BorderFactory.createBevelBorder(BevelBorder.LOWERED)));

    taglist.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    final JScrollPane tagScrollPane = new JScrollPane(taglist);
    tagScrollPane.setBorder(null);

    final JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.add(inputField, BorderLayout.NORTH);
    centerPanel.add(tagScrollPane, BorderLayout.CENTER);
    centerPanel.setMaximumSize(new Dimension(250, 500));
    centerPanel.setPreferredSize(new Dimension(200, 200));

    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(Box.createHorizontalGlue());
    add(centerPanel);
    add(Box.createHorizontalGlue());

}

From source file:be.ac.ua.comp.scarletnebula.gui.DecoratedCommunicationPanel.java

final public void clearAndFill(final Collection<Server> selectedServers) {

    // Remove all components on there
    invalidate();/*from  www  .  jav a  2s.  c  o m*/
    removeAll();

    setLayout(new BorderLayout());

    // If there are no servers, or none of the servers are running, do not
    // display the ssh console
    final Collection<Server> connectableServers = new ArrayList<Server>();
    for (final Server s : selectedServers) {
        if (s.getStatus() == VmState.RUNNING && s.getPublicDnsAddress() != null) {
            connectableServers.add(s);
        }
    }

    // If there are no servers to connect to, don't draw the ssh console
    if (connectableServers.size() == 0) {
        log.info("Connection tab clicked and no servers selected to connect to.");
        final BetterTextLabel txt = new BetterTextLabel(
                "Please select at least one running server to connect to.");
        txt.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 20));
        add(txt, BorderLayout.CENTER);
        validate();
        repaint();
    } else {
        final Server connectServer = selectedServers.iterator().next();

        final JPanel propertiesPanel = new JPanel();
        propertiesPanel.setLayout(new BoxLayout(propertiesPanel, BoxLayout.LINE_AXIS));
        propertiesPanel.add(Box.createHorizontalGlue());
        final JButton propertiesButton = new JButton("Properties", Utils.icon("modify16.png"));
        propertiesButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                final ChangeServerSshLoginMethodWindow win = new ChangeServerSshLoginMethodWindow(parent,
                        connectServer);
                win.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        clearAndFill(selectedServers);
                    }
                });
                win.setVisible(true);
            }
        });

        final JButton restartButton = new JButton("Restart connection", Utils.icon("undo16.png"));
        restartButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                clearAndFill(selectedServers);
            }
        });
        propertiesPanel.add(restartButton);
        propertiesPanel.add(Box.createHorizontalStrut(10));
        propertiesPanel.add(propertiesButton);
        propertiesPanel.add(Box.createHorizontalStrut(20));
        propertiesPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        add(propertiesPanel, BorderLayout.NORTH);

        final SSHPanel sshPanel = new SSHPanel(connectServer);
        sshPanel.setBorder(BorderFactory.createEmptyBorder(5, 20, 10, 20));
        add(sshPanel, BorderLayout.CENTER);

        validate();
        repaint();
    }
}

From source file:fungus.MycoNodeFrame.java

public MycoNodeFrame(MycoNode node) {
    this.node = node;
    this.setTitle("Node " + node.getID());

    graph = JungGraphObserver.getGraph();

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(7, 2));
    JPanel neighborPane = new JPanel();
    neighborPane.setLayout(new BoxLayout(neighborPane, BoxLayout.PAGE_AXIS));
    JPanel logPane = new JPanel();
    logPane.setLayout(new BoxLayout(logPane, BoxLayout.PAGE_AXIS));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    loggingTextArea = new JTextArea("", 25, 100);
    loggingTextArea.setLineWrap(true);//from w ww.  j a  va  2s .co m
    loggingTextArea.setEditable(false);
    handler = new MycoNodeLogHandler(node, loggingTextArea);
    handler.addChangeListener(this);
    JScrollPane logScrollPane = new JScrollPane(loggingTextArea);
    logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    logPane.add(logScrollPane);

    contentPane.add(labelPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(neighborPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(logPane);
    contentPane.add(buttonPane);

    data = node.getHyphaData();
    link = node.getHyphaLink();
    mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    stateLabel = new JLabel();
    typeLabel = new JLabel();
    queueLengthLabel = new JLabel();
    sameLabel = new JLabel();
    differentLabel = new JLabel();
    maxCapacityLabel = new JLabel();
    idealImmobileLabel = new JLabel();
    idealHyphaeLabel = new JLabel();
    idealBiomassLabel = new JLabel();
    degreeLabel = new JLabel();
    hyphaDegreeLabel = new JLabel();
    biomassDegreeLabel = new JLabel();
    hyphaUtilizationLabel = new JLabel();
    biomassUtilizationLabel = new JLabel();
    capacityUtilizationLabel = new JLabel();

    labelPane.add(new JLabel("state"));
    labelPane.add(stateLabel);
    labelPane.add(new JLabel("type"));
    labelPane.add(typeLabel);
    labelPane.add(new JLabel("queue"));
    labelPane.add(queueLengthLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("same"));
    labelPane.add(sameLabel);
    labelPane.add(new JLabel("different"));
    labelPane.add(differentLabel);
    //labelPane.add(new JLabel("immobile"));
    //labelPane.add(idealImmobileLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("actual"));
    labelPane.add(new JLabel("ideal"));
    labelPane.add(new JLabel("utilization"));
    labelPane.add(new JLabel("hyphae"));
    labelPane.add(hyphaDegreeLabel);
    labelPane.add(idealHyphaeLabel);
    labelPane.add(hyphaUtilizationLabel);
    labelPane.add(new JLabel("biomass"));
    labelPane.add(biomassDegreeLabel);
    labelPane.add(idealBiomassLabel);
    labelPane.add(biomassUtilizationLabel);
    labelPane.add(new JLabel("capacity"));
    labelPane.add(degreeLabel);
    labelPane.add(maxCapacityLabel);
    labelPane.add(capacityUtilizationLabel);

    neighborListControl = new JList();
    neighborListControl.setLayoutOrientation(JList.VERTICAL_WRAP);
    neighborListControl.setVisibleRowCount(-1);

    neighborListScroller = new JScrollPane(neighborListControl);
    neighborListScroller.setPreferredSize(new Dimension(250, 150));
    neighborListScroller.setMinimumSize(new Dimension(250, 150));

    neighborPane.add(neighborListScroller);

    JButton updateButton = new JButton("Refresh");
    ActionListener updater = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshData();
        }
    };
    updateButton.addActionListener(updater);

    JButton closeButton = new JButton("Close");
    ActionListener closer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeFrame();
        }
    };
    closeButton.addActionListener(closer);

    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(updateButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);

    refreshData();

    JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:mergedoc.ui.MergeDocFrame.java

/**
 * ??????/*  w w w  .j  ava2  s  .c om*/
 * @throws MergeDocException ?????
 */
private void initComponent() throws MergeDocException {

    // ????
    preferencePanel = new PreferencePanel();
    mergeManager = new MergeManager();

    // ???
    mainPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    mainPanel.add(preferencePanel);

    // ??????
    JPanel outerPanel = new JPanel();
    outerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS));
    outerPanel.add(mainPanel);
    outerPanel.add(ComponentFactory.createSpacer(0, 7));
    outerPanel.add(buttonBar);
    getContentPane().add(outerPanel);

    // ?
    initListener();
    buttonBar.setState(buttonBar.INIT_STATE);

    // 
    ConfigManager config = ConfigManager.getInstance();
    String iconPath = config.getFile("icon.png").toString();
    Image icon = Toolkit.getDefaultToolkit().createImage(iconPath);
    setIconImage(icon);

    // 
    setTitle(SETTING_TITLE);
    Persister psst = Persister.getInstance();
    setLocation(psst.getInt(Persister.WINDOW_X, 0), psst.getInt(Persister.WINDOW_Y, 0));
    setSize(psst.getInt(Persister.WINDOW_WIDTH, 700), psst.getInt(Persister.WINDOW_HEIGHT, 570));
    int state = psst.getInt(Persister.WINDOW_STATE, NORMAL);
    if ((state & Frame.ICONIFIED) != ICONIFIED) {
        setExtendedState(state);
    }
    setVisible(true);
}

From source file:BorderDemo.java

public BorderDemo() {
    super("BorderDemo");
    Border blackline, etched, raisedbevel, loweredbevel, empty;

    //A border that puts 10 extra pixels at the sides and
    //bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    etched = BorderFactory.createEtchedBorder();
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    //First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);/*  www. j  a  v  a 2  s.com*/
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(etched, "etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    //Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    //XXX: We *should* size the component so that the
    //XXX: icons tile OK. Without that, the icons are
    //XXX: likely to be cut off and look bad.
    ImageIcon icon = new ImageIcon("images/left.gif"); //20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);
    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);

    //Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(etched, "title");
    addCompForTitledBorder(titled, "titled etched border" + " (right just., default pos.)", TitledBorder.RIGHT,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    //Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);

    getContentPane().add(tabbedPane, BorderLayout.CENTER);
}

From source file:medsavant.uhn.cancer.SetCommentStatusDialog.java

private JPanel getMainPanel() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    //Status box.
    mainPanel.add(getStatusEditorPanel());

    //Comment box.
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(Box.createHorizontalGlue());
    comment = new JTextArea();
    p.add(comment);// w  w  w  .j  a  va 2s.  c om
    p.add(Box.createHorizontalGlue());
    mainPanel.add(p);

    //Button box.        
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(Box.createHorizontalGlue());
    JButton OKButton = new JButton("Update status");
    OKButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                updateStatus();
                dispose();
            } catch (Exception ex) {
                LOG.error(ex.getMessage(), ex);
                DialogUtils.displayException("Error", ex.getMessage(), ex);
            }
        }
    });

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    p.add(OKButton);
    p.add(cancelButton);
    p.add(Box.createHorizontalGlue());
    mainPanel.add(p);

    return mainPanel;
}

From source file:components.BorderDemo.java

public BorderDemo() {
    super(new GridLayout(1, 0));

    //Keep references to the next few borders,
    //for use in titles and compound borders.
    Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty;

    //A border that puts 10 extra pixels at the sides and
    //bottom of each pane.
    Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10);

    blackline = BorderFactory.createLineBorder(Color.black);
    raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    raisedbevel = BorderFactory.createRaisedBevelBorder();
    loweredbevel = BorderFactory.createLoweredBevelBorder();
    empty = BorderFactory.createEmptyBorder();

    //First pane: simple borders
    JPanel simpleBorders = new JPanel();
    simpleBorders.setBorder(paneEdge);/*from w ww . ja  v a2  s  .com*/
    simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS));

    addCompForBorder(blackline, "line border", simpleBorders);
    addCompForBorder(raisedetched, "raised etched border", simpleBorders);
    addCompForBorder(loweredetched, "lowered etched border", simpleBorders);
    addCompForBorder(raisedbevel, "raised bevel border", simpleBorders);
    addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders);
    addCompForBorder(empty, "empty border", simpleBorders);

    //Second pane: matte borders
    JPanel matteBorders = new JPanel();
    matteBorders.setBorder(paneEdge);
    matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS));

    ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); //20x22
    Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders);
    }
    border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red);
    addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders);

    border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon);
    if (icon != null) {
        addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders);
    } else {
        addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders);
    }

    //Third pane: titled borders
    JPanel titledBorders = new JPanel();
    titledBorders.setBorder(paneEdge);
    titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS));
    TitledBorder titled;

    titled = BorderFactory.createTitledBorder("title");
    addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders);

    titled = BorderFactory.createTitledBorder(blackline, "title");
    addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredetched, "title");
    addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)",
            TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders);

    titled = BorderFactory.createTitledBorder(loweredbevel, "title");
    addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders);

    titled = BorderFactory.createTitledBorder(empty, "title");
    addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders);

    //Fourth pane: compound borders
    JPanel compoundBorders = new JPanel();
    compoundBorders.setBorder(paneEdge);
    compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS));
    Border redline = BorderFactory.createLineBorder(Color.red);

    Border compound;
    compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    addCompForBorder(compound, "compound border (two bevels)", compoundBorders);

    compound = BorderFactory.createCompoundBorder(redline, compound);
    addCompForBorder(compound, "compound border (add a red outline)", compoundBorders);

    titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER,
            TitledBorder.BELOW_BOTTOM);
    addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple", null, simpleBorders, null);
    tabbedPane.addTab("Matte", null, matteBorders, null);
    tabbedPane.addTab("Titled", null, titledBorders, null);
    tabbedPane.addTab("Compound", null, compoundBorders, null);
    tabbedPane.setSelectedIndex(0);
    String toolTip = new String(
            "<html>Blue Wavy Line border art crew:<br>&nbsp;&nbsp;&nbsp;Bill Pauley<br>&nbsp;&nbsp;&nbsp;Cris St. Aubyn<br>&nbsp;&nbsp;&nbsp;Ben Wronsky<br>&nbsp;&nbsp;&nbsp;Nathan Walrath<br>&nbsp;&nbsp;&nbsp;Tommy Adams, special consultant</html>");
    tabbedPane.setToolTipTextAt(1, toolTip);

    add(tabbedPane);
}

From source file:gdt.jgui.entity.JEntityStructurePanel.java

/**
 * The default constructor./*from  w  w  w .j  av a  2 s.c  o  m*/
 */
public JEntityStructurePanel() {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    scrollPane = new JScrollPane();
    add(scrollPane);
    popup = new JPopupMenu();
    popup.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            popup.removeAll();
            JMenuItem facetsItem = new JMenuItem("Facets");
            popup.add(facetsItem);
            facetsItem.setHorizontalTextPosition(JMenuItem.RIGHT);
            facetsItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    //   System.out.println("EntityStructurePanel:renderer:component locator$="+nodeLocator$);
                    JEntityFacetPanel efp = new JEntityFacetPanel();
                    String efpLocator$ = efp.getLocator();
                    Properties locator = Locator.toProperties(selection$);
                    String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                    String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                    efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$);
                    efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, efpLocator$);
                }
            });
            JMenuItem copyItem = new JMenuItem("Copy");
            popup.add(copyItem);
            copyItem.setHorizontalTextPosition(JMenuItem.RIGHT);
            copyItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    console.clipboard.clear();
                    String locator$ = (String) node.getUserObject();
                    if (locator$ != null)
                        console.clipboard.putString(locator$);
                }
            });

            if (!isFirst) {
                popup.addSeparator();
                JMenuItem excludeItem = new JMenuItem("Exclude");
                popup.add(excludeItem);
                excludeItem.setHorizontalTextPosition(JMenuItem.RIGHT);
                excludeItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Exclude ?",
                                "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION) {
                            try {
                                Properties locator = Locator.toProperties(selection$);
                                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                                Entigrator entigrator = console.getEntigrator(entihome$);
                                Sack component = entigrator.getEntityAtKey(entityKey$);
                                String[] sa = entigrator.ent_listContainers(component);
                                if (sa != null) {
                                    Sack container;
                                    for (String aSa : sa) {
                                        container = entigrator.getEntityAtKey(aSa);
                                        if (container != null)
                                            entigrator.col_breakRelation(container, component);
                                    }
                                }
                                JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$);
                            } catch (Exception ee) {
                                Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString());
                            }
                        }
                    }
                });

                JMenuItem deleteItem = new JMenuItem("Delete");
                popup.add(deleteItem);
                deleteItem.setHorizontalTextPosition(JMenuItem.RIGHT);
                deleteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?",
                                "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION) {
                            try {
                                Properties locator = Locator.toProperties(selection$);
                                String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
                                String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
                                Entigrator entigrator = console.getEntigrator(entihome$);
                                Sack component = entigrator.getEntityAtKey(entityKey$);
                                entigrator.deleteEntity(component);
                                JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$);
                            } catch (Exception ee) {
                                Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString());
                            }
                        }
                    }
                });
            }
            if (hasToInclude()) {
                popup.addSeparator();
                JMenuItem includeItem = new JMenuItem("Include");
                popup.add(includeItem);
                includeItem.setHorizontalTextPosition(JMenuItem.RIGHT);
                includeItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        include();
                        JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$);
                    }
                });
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // TODO Auto-generated method stub
        }
    });
}

From source file:com.jdom.util.patterns.mvp.swing.RadioButtonGroupDialog.java

private RadioButtonGroupDialog(Frame frame, Component locationComp, String labelText, String title,
        Collection<String> data, String initialValue, String longValue) {
    super(frame, title, true);

    final JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);

    final JButton setButton = new JButton("OK");
    setButton.setActionCommand("OK");
    setButton.addActionListener(this);
    getRootPane().setDefaultButton(setButton);

    ButtonGroup radioButtonGroup = new ButtonGroup();
    for (String option : data) {
        JRadioButton button = new JRadioButton(option);
        if (option.equals(initialValue)) {
            button.setSelected(true);//from   w  w  w  .j a  v a  2 s .com
        }
        radioButtonGroup.add(button);
        panel.add(button);
    }

    JScrollPane listScroller = new JScrollPane(panel);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setAlignmentX(LEFT_ALIGNMENT);

    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));

    if (!StringUtils.isEmpty(labelText)) {
        JLabel label = new JLabel(labelText);
        label.setText(labelText);
        listPane.add(label);
    }
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(listScroller);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(setButton);

    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    pack();
    setLocationRelativeTo(locationComp);
}