Example usage for javax.swing BorderFactory createEmptyBorder

List of usage examples for javax.swing BorderFactory createEmptyBorder

Introduction

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

Prototype

public static Border createEmptyBorder(int top, int left, int bottom, int right) 

Source Link

Document

Creates an empty border that takes up space but which does no drawing, specifying the width of the top, left, bottom, and right sides.

Usage

From source file:hermes.browser.dialog.EditNamingConfigDialog.java

public ButtonPanel createButtonPanel() {
    final ButtonPanel buttonPanel = new ButtonPanel();
    final JButton okButton = new JButton("OK");
    final JButton cancelButton = new JButton("Cancel");

    buttonPanel.addButton(okButton);/*from w  w w  . ja va 2s.com*/
    buttonPanel.addButton(cancelButton);

    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            onOK();
            dispose();

        }
    });

    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });

    buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    return buttonPanel;
}

From source file:edu.ku.brc.ui.CustomFrame.java

/**
 * Create the UI for the frame.//w ww  .  ja v a 2s  .c om
 */
public void createUI() {
    mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 10));

    if (contentPanel != null) {
        mainPanel.add(contentPanel, BorderLayout.CENTER);
    }

    // Bottom Button UI
    okBtn = createButton(StringUtils.isNotEmpty(okLabel) ? okLabel : getResourceString("OK"));
    okBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            okButtonPressed();
        }
    });
    getRootPane().setDefaultButton(okBtn);

    if ((whichBtns & CANCEL_BTN) == CANCEL_BTN) {
        cancelBtn = createButton(
                StringUtils.isNotEmpty(cancelLabel) ? cancelLabel : getResourceString("CANCEL"));
        cancelBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                cancelButtonPressed();
            }
        });
    }

    if ((whichBtns & HELP_BTN) == HELP_BTN) {
        helpBtn = createButton(StringUtils.isNotEmpty(cancelLabel) ? cancelLabel : getResourceString("HELP"));
        if (StringUtils.isNotEmpty(helpContext)) {
            HelpMgr.registerComponent(helpBtn, helpContext);
        } else {
            helpBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    helpButtonPressed();
                }
            });
        }
    }

    if ((whichBtns & APPLY_BTN) == APPLY_BTN) {
        applyBtn = createButton(StringUtils.isNotEmpty(applyLabel) ? applyLabel : getResourceString("Apply"));
        applyBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                applyButtonPressed();
            }
        });
    }

    JPanel bb;
    if (whichBtns == OK_BTN) {
        bb = ButtonBarFactory.buildOKBar(okBtn);

    } else if (whichBtns == OKCANCEL) {
        bb = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);

    } else if (whichBtns == OKCANCELAPPLY) {
        bb = ButtonBarFactory.buildOKCancelApplyBar(okBtn, cancelBtn, applyBtn);

    } else if (whichBtns == OKHELP) {
        bb = ButtonBarFactory.buildOKHelpBar(okBtn, helpBtn);

    } else if (whichBtns == OKCANCELHELP) {
        bb = ButtonBarFactory.buildOKCancelHelpBar(okBtn, cancelBtn, helpBtn);

    } else if (whichBtns == OKCANCELAPPLYHELP) {
        bb = ButtonBarFactory.buildOKCancelApplyHelpBar(okBtn, cancelBtn, applyBtn, helpBtn);

    } else {
        bb = ButtonBarFactory.buildOKBar(okBtn);
    }

    mainPanel.add(bb, BorderLayout.SOUTH);

    super.setContentPane(mainPanel);

    pack();

    setLocationRelativeTo(this.getOwner());
}

From source file:org.jfree.chart.demo.SuperDemo.java

private JComponent createContent() {
    JPanel jpanel = new JPanel(new BorderLayout());
    JTabbedPane jtabbedpane = new JTabbedPane();
    JPanel jpanel1 = new JPanel(new BorderLayout());
    jpanel1.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    JSplitPane jsplitpane = new JSplitPane(1);
    JTree jtree = new JTree(createTreeModel());
    jtree.addTreeSelectionListener(this);
    JScrollPane jscrollpane = new JScrollPane(jtree);
    jscrollpane.setPreferredSize(new Dimension(300, 100));
    jsplitpane.setLeftComponent(jscrollpane);
    jsplitpane.setRightComponent(createChartDisplayPanel());
    jpanel1.add(jsplitpane);//from w  w w .  j  av  a  2s.  c om
    jtabbedpane.add("Demos", jpanel1);
    MemoryUsageDemo memoryusagedemo = new MemoryUsageDemo(0x493e0);
    (memoryusagedemo.new DataGenerator(1000)).start();//memoryusagedemo, 
    jtabbedpane.add("Memory Usage", memoryusagedemo);
    jtabbedpane.add("Source Code", createSourceCodePanel());
    jtabbedpane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    jpanel.add(jtabbedpane);
    return jpanel;
}

From source file:DragPictureDemo.java

public DragPictureDemo() {
    super(new BorderLayout());
    picHandler = new PictureTransferHandler();

    JPanel mugshots = new JPanel(new GridLayout(4, 3));
    pic1 = new DTPicture(createImageIcon("images/" + mayaString + ".jpg", mayaString).getImage());
    pic1.setTransferHandler(picHandler);
    mugshots.add(pic1);//from   w  w w . j  a v  a  2s. c o  m
    pic2 = new DTPicture(createImageIcon("images/" + anyaString + ".jpg", anyaString).getImage());
    pic2.setTransferHandler(picHandler);
    mugshots.add(pic2);
    pic3 = new DTPicture(createImageIcon("images/" + laineString + ".jpg", laineString).getImage());
    pic3.setTransferHandler(picHandler);
    mugshots.add(pic3);
    pic4 = new DTPicture(createImageIcon("images/" + cosmoString + ".jpg", cosmoString).getImage());
    pic4.setTransferHandler(picHandler);
    mugshots.add(pic4);
    pic5 = new DTPicture(createImageIcon("images/" + adeleString + ".jpg", adeleString).getImage());
    pic5.setTransferHandler(picHandler);
    mugshots.add(pic5);
    pic6 = new DTPicture(createImageIcon("images/" + alexiString + ".jpg", alexiString).getImage());
    pic6.setTransferHandler(picHandler);
    mugshots.add(pic6);

    //These six components with no pictures provide handy
    //drop targets.
    pic7 = new DTPicture(null);
    pic7.setTransferHandler(picHandler);
    mugshots.add(pic7);
    pic8 = new DTPicture(null);
    pic8.setTransferHandler(picHandler);
    mugshots.add(pic8);
    pic9 = new DTPicture(null);
    pic9.setTransferHandler(picHandler);
    mugshots.add(pic9);
    pic10 = new DTPicture(null);
    pic10.setTransferHandler(picHandler);
    mugshots.add(pic10);
    pic11 = new DTPicture(null);
    pic11.setTransferHandler(picHandler);
    mugshots.add(pic11);
    pic12 = new DTPicture(null);
    pic12.setTransferHandler(picHandler);
    mugshots.add(pic12);

    setPreferredSize(new Dimension(450, 630));
    add(mugshots, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:org.pgptool.gui.ui.mainframe.MainFrameView.java

private void initFormComponents() {
    lblNoDataToDisplay = new JLabel(Messages.get("phrase.noDecryptedFilesAreMonitoredAtTheMoment"));
    lblNoDataToDisplay.setHorizontalAlignment(JLabel.CENTER);

    SgLayout sgl = new SgLayout(1, 3, 0, 0);
    sgl.setColSize(0, 100, SgLayout.SIZE_TYPE_WEIGHTED);
    sgl.setRowSize(1, 100, SgLayout.SIZE_TYPE_WEIGHTED);
    panelRoot = new JPanel(sgl);
    panelRoot.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));

    int row = 0;/*ww  w  .  jav  a  2 s  . c  om*/
    JLabel lblPrevDecryptedFiles = new JLabel(
            UiUtils.plainToBoldHtmlString(text("phrase.previouslyDecrpytedFiles")));
    panelRoot.add(lblPrevDecryptedFiles, sgl.cs(0, row));
    lblPrevDecryptedFiles.setBorder(BorderFactory.createEmptyBorder(14, 0, 0, 0));

    row++;
    panelTablePlaceholder = new JPanel(new BorderLayout());
    panelTablePlaceholder.add(initTableComponent(), BorderLayout.CENTER);
    panelRoot.add(panelTablePlaceholder, sgl.cs(0, row));

    // add message panel
    row++;
    hintsPanel = new JPanel(new BorderLayout());
    panelRoot.add(hintsPanel, sgl.cs(0, row));
    // hintView.renderTo(hintsPanel, BorderLayout.CENTER);
}

From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java

public NumberComposite() {

    setName("Number to Composite");
    //        System.out.println("Created a new NumberComposite");
    setDescription("A renderer that can be used to assign renderers to different aggregations");

    configUI.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;//w  w  w  . jav  a  2 s. c  om
    c.gridy = 0;
    c.ipadx = 5;
    c.ipady = 5;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridwidth = 1;

    //This combo box will need to be able to add registered
    singleComboBox = new JComboBox();
    rowComboBox = new JComboBox();
    columnComboBox = new JComboBox();
    rowColumnComboBox = new JComboBox();

    singleLegend = new JLabel();
    rowLegend = new JLabel();
    columnLegend = new JLabel();
    rowColumnLegend = new JLabel();

    singleLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    columnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowColumnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    //Add them
    JLabel label = new JLabel("Default:");
    label.setToolTipText("Default renderer");
    c.gridx = 0;
    c.gridy++;
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(singleComboBox, c);
    singleComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 2;
    JButton config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (singleRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    singleRenderer.getConfigUI(), "Default Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(singleLegend, c);

    //////////////////////////////////////////////////////////////
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row Group:");
    label.setToolTipText("Renderer for row ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowGroupRenderer.getConfigUI(), "Row Group Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }

        }
    });
    rowComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowLegend, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Column Group:");
    label.setToolTipText("Renderer for column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(columnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (columnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    columnGroupRenderer.getConfigUI(), "Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(columnLegend, c);
    columnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row & Column Group:");
    label.setToolTipText("Renderer for row and column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowColumnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowColumnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowColumnGroupRenderer.getConfigUI(), "Row + Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });
    rowColumnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowColumnLegend, c);

    JButton button = new JButton("Apply Changes", UI.getImageIcon("refresh"));
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRenderer();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    configUI.add(button, c);

    singleComboBox.setRenderer(new ComboRenderer());
    rowComboBox.setRenderer(new ComboRenderer());
    columnComboBox.setRenderer(new ComboRenderer());
    rowColumnComboBox.setRenderer(new ComboRenderer());

    _updateLists();

}

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

/**
 * Creates a new SshToolsConnectionKerberosTab object.
 *//*from  w ww  .ja v a  2 s  .  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:com.mirth.connect.manager.ManagerDialog.java

private void initServicePanel() {
    servicePanel = new JPanel(
            new MigLayout("insets 8, novisualpadding, hidemode 3", "24[][][]", "[]12[]12[]12[]12[]"));
    servicePanel.setBackground(new Color(255, 255, 255));
    servicePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    servicePanel.setFocusable(false);//from   w w w .j  a  v a2  s. c  o m

    startButton = new JButton("Start");
    startButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            startButtonActionPerformed(evt);
        }
    });
    startLabel = new JLabel("Starts the Mirth Connect service");

    restartButton = new JButton("Restart");
    restartButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            restartButtonActionPerformed(evt);
        }
    });
    restartLabel = new JLabel("Restarts the Mirth Connect service");

    stopButton = new JButton("Stop");
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            stopButtonActionPerformed(evt);
        }
    });
    stopLabel = new JLabel("Stops the Mirth Connect service");

    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            refreshButtonActionPerformed(evt);
        }
    });
    refreshLabel = new JLabel("Refreshes the Mirth Connect service status");

    startup = new JCheckBox("Start Mirth Connect Server Manager on system startup");
    startup.setFocusable(false);
    startup.setToolTipText(
            "Starts this application when logging into the operating system. Currently only enabled for Windows.");
    startup.setBackground(new Color(255, 255, 255));
    startup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            startupActionPerformed(evt);
        }
    });
}

From source file:api3.window.sound.panel.SoundPanel.java

public void plot(PanelData data, JFreeChart chart, JPanel plotPanel) {
    chart = ChartFactory.createXYLineChart(data.name, "prbka", "warto", data.dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    LOG.info("PLOTTING      1");
    domainAxis = (NumberAxis) plot.getDomainAxis();
    plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1)));

    ChartPanel chartPanel = new ChartPanel(chart);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    chartPanel.setBorder(border);/* w  w  w  .j  a v a  2  s.co m*/
    LOG.info("PLOTTING      2");
    plotPanel.removeAll();
    plotPanel.add(chartPanel);
    plotPanel.revalidate();
    LOG.info("PLOTTING      3");
}

From source file:components.SharedModelDemo.java

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

    Vector data = new Vector(7);
    String[] columnNames = { "French", "Spanish", "Italian" };
    String[] oneData = { "un", "uno", "uno" };
    String[] twoData = { "deux", "dos", "due" };
    String[] threeData = { "trois", "tres", "tre" };
    String[] fourData = { "quatre", "cuatro", "quattro" };
    String[] fiveData = { "cinq", "cinco", "cinque" };
    String[] sixData = { "six", "seis", "sei" };
    String[] sevenData = { "sept", "siete", "sette" };

    //Build the model.
    SharedDataModel dataModel = new SharedDataModel(columnNames);
    dataModel.addElement(oneData);//from  w  ww.j a  v a  2  s . com
    dataModel.addElement(twoData);
    dataModel.addElement(threeData);
    dataModel.addElement(fourData);
    dataModel.addElement(fiveData);
    dataModel.addElement(sixData);
    dataModel.addElement(sevenData);

    list = new JList(dataModel);
    list.setCellRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList l, Object value, int i, boolean s, boolean f) {
            String[] array = (String[]) value;
            return super.getListCellRendererComponent(l, array[0], i, s, f);
        }
    });

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

    table = new JTable(dataModel);
    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);
    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(10, 40);
    output.setEditable(false);
    JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

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

    JPanel topHalf = new JPanel();
    topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.X_AXIS));
    JPanel listContainer = new JPanel(new GridLayout(1, 1));
    listContainer.setBorder(BorderFactory.createTitledBorder("List"));
    listContainer.add(listPane);
    JPanel tableContainer = new JPanel(new GridLayout(1, 1));
    tableContainer.setBorder(BorderFactory.createTitledBorder("Table"));
    tableContainer.add(tablePane);
    tablePane.setPreferredSize(new Dimension(300, 100));
    topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    topHalf.add(listContainer);
    topHalf.add(tableContainer);

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

    JPanel bottomHalf = new JPanel(new BorderLayout());
    bottomHalf.add(controlPane, BorderLayout.NORTH);
    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);
}