Example usage for javax.swing BorderFactory createTitledBorder

List of usage examples for javax.swing BorderFactory createTitledBorder

Introduction

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

Prototype

public static TitledBorder createTitledBorder(Border border) 

Source Link

Document

Creates a new titled border with an empty title, the specified border object, the default text position (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

Usage

From source file:it.cnr.icar.eric.client.ui.swing.DiscoveryPanel.java

private JPanel createFindResultsPanel() {
    //The registryObjectsTable
    registryObjectsTablePanel = new JPanel();
    registryObjectsTablePanelBorder = BorderFactory
            .createTitledBorder(resourceBundle.getString("title.searchResults"));
    registryObjectsTablePanel.setBorder(registryObjectsTablePanelBorder);

    registryObjectsTablePanel.setLayout(new BorderLayout());

    registryObjectsTableModel = new RegistryObjectsTableModel();

    TableSorter sorter = new TableSorter(registryObjectsTableModel);
    registryObjectsTable = new RegistryObjectsTable(sorter);
    sorter.addMouseListenerToHeaderInTable(registryObjectsTable);

    registryObjectsTablePane = new JScrollPane(registryObjectsTable);
    registryObjectsTablePanel.add(registryObjectsTablePane, BorderLayout.CENTER);

    return registryObjectsTablePanel;
}

From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java

/**
 * Creates a new SshToolsConnectionKerberosTab object.
 *//*from w w  w.j a v a 2s.  co  m*/
public SshToolsConnectionKerberosTab() {
    super();

    //  Create the main connection details panel
    JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(0, 2, 2, 2);
    //  enabled option
    //gbc.fill = GridBagConstraints.NONE;
    useKerberos = new JCheckBox("Use MyProxy Kerberos support");
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, useKerberos, gbc, GridBagConstraints.REMAINDER);
    //  Host name
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.NONE;

    //  Username
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);
    //gbc.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER);

    JPanel settingsPanel = new JPanel(new GridBagLayout());
    settingsPanel
            .setBorder(BorderFactory.createTitledBorder("Settings if krb5.conf or krb5.ini file not found: "));
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    gbc2.anchor = GridBagConstraints.NORTHWEST;
    gbc2.insets = new Insets(0, 2, 2, 2);
    gbc2.weightx = 1.0;

    //  realm
    UIUtil.jGridBagAdd(settingsPanel, new JLabel("Realm"), gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(settingsPanel, jTextRealm, gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.NONE;

    //  kdc
    UIUtil.jGridBagAdd(settingsPanel, new JLabel("KDC"), gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    gbc2.weighty = 1.0;
    UIUtil.jGridBagAdd(settingsPanel, jTextKDC, gbc2, GridBagConstraints.REMAINDER);
    gbc2.fill = GridBagConstraints.NONE;

    //
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = new Insets(4, 2, 2, 2);
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, settingsPanel, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel(
            new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), mainConnectionDetailsPanel);

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(this, iconMainConnectionDetailsPanel, gbc, GridBagConstraints.REMAINDER);

}

From source file:edu.uci.ics.jung.samples.ImageEdgeLabelDemo.java

@SuppressWarnings("rawtypes")
public ImageEdgeLabelDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseMultigraph<Number, Number>();
    createGraph(VERTEX_COUNT);//ww w  .  j a  v a  2  s  . com

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Number, String>() {
        URL url = getClass().getResource("/images/lightning-s.gif");

        public String transform(Number input) {
            return "<html><img src=" + url + " height=10 width=21>";
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());
    vv.setEdgeToolTipTransformer(new ToStringLabeller<Number>());
    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);
    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:com.joey.software.Tools.AScanViewerTool.java

public void createJPanel() {
    JSplitPane graphSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    graphSplit.setLeftComponent(previewPanel);
    graphSplit.setRightComponent(dataPanel);
    graphSplit.setOneTouchExpandable(true);
    graphSplit.setDividerLocation(400);//w w w  . j  a va  2  s. c om

    JPanel graphHolder = new JPanel(new BorderLayout());
    graphHolder.add(graphSplit, BorderLayout.CENTER);
    graphHolder.setBorder(BorderFactory.createTitledBorder(""));

    JPanel tool = new JPanel(new BorderLayout());
    tool.add(saveCSVData, BorderLayout.SOUTH);
    tool.add(aScanType, BorderLayout.CENTER);

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(graphHolder, BorderLayout.CENTER);
    leftPanel.add(tool, BorderLayout.SOUTH);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.setOneTouchExpandable(true);
    split.setRightComponent(imageViewPanel);
    split.setLeftComponent(leftPanel);
    split.setDividerLocation(600);

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(split, BorderLayout.CENTER);

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

    aScanType.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            imageViewPanel.setViewType(aScanType.getSelectedIndex());

        }
    });
    saveCSVData.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                File f = FileSelectionField.getUserFile();
                f = FileOperations.renameFileType(f, "csv");
                saveAScanData(f);
            } catch (Exception e1) {
                JOptionPane.showMessageDialog(null, "Error : " + e1.getLocalizedMessage(), "Error Saving Data",
                        JOptionPane.ERROR_MESSAGE);
                e1.printStackTrace();
            }
        }
    });
}

From source file:ExtendedDnDDemo.java

private JPanel createArea() {
    String text = "This is the text that I want to show.";

    JTextArea area = new JTextArea();
    area.setText(text);//from  ww  w. ja va  2s .co  m
    area.setDragEnabled(true);
    JScrollPane scrollPane = new JScrollPane(area);
    scrollPane.setPreferredSize(new Dimension(400, 100));
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setBorder(BorderFactory.createTitledBorder("Text Area"));
    return panel;
}

From source file:events.TableListSelectionDemo.java

public TableListSelectionDemo() {
    super(new BorderLayout());

    String[] columnNames = { "French", "Spanish", "Italian" };
    String[][] tableData = { { "un", "uno", "uno" }, { "deux", "dos", "due" }, { "trois", "tres", "tre" },
            { "quatre", "cuatro", "quattro" }, { "cinq", "cinco", "cinque" }, { "six", "seis", "sei" },
            { "sept", "siete", "sette" } };

    table = new JTable(tableData, columnNames);
    listSelectionModel = table.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    table.setSelectionModel(listSelectionModel);
    JScrollPane tablePane = new JScrollPane(table);

    //Build control area (use default FlowLayout).
    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);//from   w  w  w. j  ava2 s.c o  m
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    //Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    //Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    JPanel tableContainer = new JPanel(new GridLayout(1, 1));
    tableContainer.setBorder(BorderFactory.createTitledBorder("Table"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(420, 130));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(250, 50));
    topHalf.setPreferredSize(new Dimension(200, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    //XXX: next line needed if bottomHalf is a scroll pane:
    //bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 110));
    splitPane.add(bottomHalf);
}

From source file:components.TextSamplerDemo.java

public TextSamplerDemo() {
    setLayout(new BorderLayout());

    //Create a regular text field.
    JTextField textField = new JTextField(10);
    textField.setActionCommand(textFieldString);
    textField.addActionListener(this);

    //Create a password field.
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setActionCommand(passwordFieldString);
    passwordField.addActionListener(this);

    //Create a formatted text field.
    JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime());
    ftf.setActionCommand(textFieldString);
    ftf.addActionListener(this);

    //Create some labels for the fields.
    JLabel textFieldLabel = new JLabel(textFieldString + ": ");
    textFieldLabel.setLabelFor(textField);
    JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": ");
    passwordFieldLabel.setLabelFor(passwordField);
    JLabel ftfLabel = new JLabel(ftfString + ": ");
    ftfLabel.setLabelFor(ftf);/*from ww w . ja  v a 2 s . co m*/

    //Create a label to put messages during an action event.
    actionLabel = new JLabel("Type text in a field and press Enter.");
    actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //Lay out the text controls and the labels.
    JPanel textControlsPane = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    textControlsPane.setLayout(gridbag);

    JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel };
    JTextField[] textFields = { textField, passwordField, ftf };
    addLabelTextRows(labels, textFields, gridbag, textControlsPane);

    c.gridwidth = GridBagConstraints.REMAINDER; //last
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    textControlsPane.add(actionLabel, c);
    textControlsPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Create a text area.
    JTextArea textArea = new JTextArea("This is an editable JTextArea. "
            + "A text area is a \"plain\" text component, " + "which means that although it can display text "
            + "in any font, all of the text is in the same font.");
    textArea.setFont(new Font("Serif", Font.ITALIC, 16));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    areaScrollPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            areaScrollPane.getBorder()));

    //Create an editor pane.
    JEditorPane editorPane = createEditorPane();
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(250, 145));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    //Create a text pane.
    JTextPane textPane = createTextPane();
    JScrollPane paneScrollPane = new JScrollPane(textPane);
    paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    paneScrollPane.setPreferredSize(new Dimension(250, 155));
    paneScrollPane.setMinimumSize(new Dimension(10, 10));

    //Put the editor pane and the text pane in a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);
    JPanel rightPane = new JPanel(new GridLayout(1, 0));
    rightPane.add(splitPane);
    rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Put everything together.
    JPanel leftPane = new JPanel(new BorderLayout());
    leftPane.add(textControlsPane, BorderLayout.PAGE_START);
    leftPane.add(areaScrollPane, BorderLayout.CENTER);

    add(leftPane, BorderLayout.LINE_START);
    add(rightPane, BorderLayout.LINE_END);
}

From source file:com.sshtools.common.ui.SshToolsConnectionProxyTab.java

/**
 * Creates a new SshToolsConnectionProxyTab object.
 *///from   w w w.ja  v  a2s. c o  m
public SshToolsConnectionProxyTab() {
    super();
    group.add(noProxy);
    group.add(httpProxy);
    group.add(socks4Proxy);
    group.add(socks5Proxy);

    ChangeListener listener = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (noProxy.isSelected()) {
                username.setEnabled(false);
                password.setEnabled(false);
                proxy.setEnabled(false);

                //port.setEnabled(false);
                port.setForeground(Color.white);
            } else {
                username.setEnabled(true);
                password.setEnabled(true);
                proxy.setEnabled(true);

                //port.setEnabled(true);
                port.setForeground(Color.black);

                if (httpProxy.isSelected()) {
                    port.setText("80");
                } else {
                    port.setText("1080");
                }
            }
        }
    };

    noProxy.getModel().addChangeListener(listener);
    httpProxy.getModel().addChangeListener(listener);
    socks4Proxy.getModel().addChangeListener(listener);
    socks5Proxy.getModel().addChangeListener(listener);

    //  Create the main connection details panel
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);
    gbc.weightx = 1.0;
    proxyframe.setBorder(BorderFactory.createTitledBorder("Connect using the following proxy"));

    //  No proxy label
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, noProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 4 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks4Proxy, gbc, GridBagConstraints.REMAINDER);

    //gbc.fill = GridBagConstraints.HORIZONTAL;
    // Http Proxy
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, httpProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 5 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks5Proxy, gbc, GridBagConstraints.REMAINDER);

    gbc.insets = new Insets(2, 10, 2, 10);

    JPanel connect = new JPanel(new GridBagLayout());
    connect.setBorder(BorderFactory.createTitledBorder("Proxy Details"));
    UIUtil.jGridBagAdd(connect, new JLabel("Host"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, proxy, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Port"), gbc, GridBagConstraints.REMAINDER);
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;

    UIUtil.jGridBagAdd(connect, port, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.HORIZONTAL;

    UIUtil.jGridBagAdd(connect, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, username, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Password"), gbc, GridBagConstraints.REMAINDER);
    gbc.insets = new Insets(2, 10, 10, 10);
    UIUtil.jGridBagAdd(connect, password, gbc, GridBagConstraints.REMAINDER);

    JPanel main = new JPanel(new GridBagLayout());
    gbc.insets = new Insets(2, 2, 2, 2);
    UIUtil.jGridBagAdd(main, proxyframe, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, connect, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(PROXY_ICON), main);
    noProxy.setSelected(true);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}

From source file:org.jdal.swing.form.FormUtils.java

/**
 * Create Titled Border//from   ww w.j  a  va  2  s. c om
 * @param name the title
 * @return Border
 */
public static Border createTitledBorder(String name) {
    Border margin = BorderFactory.createEmptyBorder(10, 10, 10, 10);
    Border title = BorderFactory.createTitledBorder(name);

    return BorderFactory.createCompoundBorder(title, margin);
}

From source file:ListSelectionDemo.java

public ListSelectionDemo() {
    super(new BorderLayout());

    String[] listData = { "one", "two", "three", "four", "five", "six", "seven" };
    String[] columnNames = { "French", "Spanish", "Italian" };
    list = new JList(listData);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    JScrollPane listPane = new JScrollPane(list);

    JPanel controlPane = new JPanel();
    String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" };

    final JComboBox comboBox = new JComboBox(modes);
    comboBox.setSelectedIndex(2);//from w  ww .  ja  va 2s. co  m
    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String newMode = (String) comboBox.getSelectedItem();
            if (newMode.equals("SINGLE_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) {
                listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            } else {
                listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            }
            output.append("----------" + "Mode: " + newMode + "----------" + newline);
        }
    });
    controlPane.add(new JLabel("Selection mode:"));
    controlPane.add(comboBox);

    // Build output area.
    output = new JTextArea(1, 10);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // Do the layout.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    add(splitPane, BorderLayout.CENTER);

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    listContainer.setBorder(BorderFactory.createTitledBorder("List"));
    listContainer.add(listPane);

    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    // topHalf.add(tableContainer);

    topHalf.setMinimumSize(new Dimension(100, 50));
    topHalf.setPreferredSize(new Dimension(100, 110));
    splitPane.add(topHalf);

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.PAGE_START);
    bottomHalf.add(outputPane, BorderLayout.CENTER);
    // XXX: next line needed if bottomHalf is a scroll pane:
    // bottomHalf.setMinimumSize(new Dimension(400, 50));
    bottomHalf.setPreferredSize(new Dimension(450, 135));
    splitPane.add(bottomHalf);
}