Example usage for javax.swing JSplitPane HORIZONTAL_SPLIT

List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT

Introduction

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

Prototype

int HORIZONTAL_SPLIT

To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.

Click Source Link

Document

Horizontal split indicates the Components are split along the x axis.

Usage

From source file:uk.co.petertribble.jangle.SnmpTreePanel.java

/**
 * Create a new SnmpTreePanel, starting exploration at the specified OID.
 *
 * @param startOID the OID to start from
 *///from  w w  w . ja  va  2s .c  om
public SnmpTreePanel(String startOID) {
    this.startOID = startOID;
    setLayout(new BorderLayout());

    jtpl = new JTabbedPane();
    model = new DefaultListModel();
    oidList = new ArrayList<SnmpObject>();
    slist = new JList(model);
    slist.addListSelectionListener(this);
    slist.setCellRenderer(new SnmpListCellRenderer());
    jtpl.add(SnmpResources.getString("SNMP.LIST.TEXT"), new JScrollPane(slist));

    // we use explicit placement so the tabs can be manipulated later
    jtpr = new JTabbedPane();

    // details tab
    jp1 = new JPanel(new BorderLayout());
    jp2 = new JPanel(new BorderLayout());
    tp = new JingleTextPane("text/plain");
    jp1.add(new JScrollPane(tp));
    // jp2 holds the chart
    jp2 = new JPanel(new BorderLayout());
    JSplitPane jpt = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jp1, jp2);
    jpt.setOneTouchExpandable(true);
    jpt.setDividerLocation(120);

    jtpr.insertTab(SnmpResources.getString("SNMP.DETAILS.TEXT"), (Icon) null, jpt, (String) null, TAB_D);

    tpdesc = new JingleTextPane("text/plain");
    jtpr.insertTab(SnmpResources.getString("SNMP.ABOUT.TEXT"), (Icon) null, new JScrollPane(tpdesc),
            (String) null, TAB_A);

    // siblings tab
    tpsiblings = new JingleTextPane("text/plain");
    jp3 = new JPanel(new BorderLayout());
    jp3t = new JPanel(new BorderLayout());
    JSplitPane jps = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jp3t, jp3);
    jps.setOneTouchExpandable(true);
    jps.setDividerLocation(200);
    jtpr.insertTab(SnmpResources.getString("SNMP.SIBLINGS.TEXT"), (Icon) null, jps, (String) null, TAB_S);

    // cousins tab
    tpcousins = new JingleTextPane("text/plain");
    jp4 = new JPanel(new BorderLayout());
    jp4t = new JPanel(new BorderLayout());
    JSplitPane jpc = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jp4t, jp4);
    jpc.setOneTouchExpandable(true);
    jpc.setDividerLocation(200);
    jtpr.insertTab(SnmpResources.getString("SNMP.COUSINS.TEXT"), (Icon) null, jpc, (String) null, TAB_C);

    // split pane to hold the lot
    JSplitPane psplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jtpl, jtpr);
    psplit.setOneTouchExpandable(true);
    psplit.setDividerLocation(200);
    add(psplit);
}

From source file:gui.TwopointPWDPanelnonsnp.java

private JPanel createControls() {
    // Marker model (for ordered list of markers)
    markerModel = new PWDTableModel();

    // Populate the marker table
    markerTable = new JTable(markerModel);
    markerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    markerTable.getColumnModel().getColumn(0).setPreferredWidth(60);
    markerTable.getColumnModel().getColumn(1).setPreferredWidth(130);
    markerTable.getColumnModel().getColumn(2).setPreferredWidth(50);// ratio
    markerTable.getColumnModel().getColumn(3).setPreferredWidth(70);// geno
    markerTable.getColumnModel().getColumn(4).setPreferredWidth(50);// p1
    markerTable.getColumnModel().getColumn(5).setPreferredWidth(50);// p2
    for (CMarker cm : order.getLinkageGroup().getMarkers()) {
        markerModel.addRow(new Object[] { cm.marker.getPrefix(), cm, cm.marker.getRatio(),
                cm.marker.getRatioGenotypes(), "0000", "0000" });
    }/*from   w ww . ja va  2s.c  om*/
    markerTable.getSelectionModel().addListSelectionListener(this);

    if (order.rows != null) {
        int row = 0;
        for (String[] data : order.rows) {
            for (int i = 0; i < 2; i++) {
                markerModel.setValueAt(data[i], row, i + 4);
            }
            row++;
        }
    } else {
        order.rows = getSelection();
    }

    // Phase model (for scores of each ordered marker against the others)
    phaseModel = new PWDTableModel2();
    phaseModel.setColumnIdentifiers(new Object[] { "Graph Code", "Marker Name", "Recom Freq", "LOD Score" });

    phaseTable = new JTable(phaseModel);
    phaseTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    phaseTable.getSelectionModel().addListSelectionListener(this);

    rfqChart = new PWDChartPanel("Recombination Freq");
    lodChart = new PWDChartPanel("LOD Score");

    m1Label = new JLabel("");
    m1Label.setFont(new Font("Monospaced", Font.PLAIN, 11));
    m2Label = new JLabel("");
    m2Label.setFont(new Font("Monospaced", Font.PLAIN, 11));

    JScrollPane mSP = new JScrollPane(markerTable);
    mSP.setPreferredSize(new Dimension(300, 10));

    JPanel p1 = new JPanel(new BorderLayout(5, 0));
    p1.add(new JLabel("Ordered Markers:"), BorderLayout.NORTH);
    p1.add(mSP);

    JPanel p2 = new JPanel(new BorderLayout(5, 0));
    p2.add(new JLabel("Scores:"), BorderLayout.NORTH);
    p2.add(new JScrollPane(phaseTable));

    JPanel p3 = new JPanel(new GridLayout(2, 1, 2, 2));
    p3.setBorder(BorderFactory.createLoweredBevelBorder());
    p3.add(m1Label);
    p3.add(m2Label);

    JPanel p4 = new JPanel(new GridLayout(1, 2, 5, 5));
    p4.add(rfqChart);
    p4.add(lodChart);

    JPanel p5 = new JPanel(new BorderLayout(5, 5));
    p5.add(p3, BorderLayout.NORTH);
    p5.add(p4, BorderLayout.CENTER);

    JSplitPane splits = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splits.setResizeWeight(0.5);
    splits.setLeftComponent(p1);
    splits.setRightComponent(p2);

    JPanel p6 = new JPanel(new BorderLayout(5, 5));
    p6.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    p6.add(splits);
    p6.add(p5, BorderLayout.SOUTH);

    return p6;
}

From source file:ja.lingo.application.gui.main.settings.dictionaries.add.AddPanel.java

public AddPanel(JDialog parentDialog, IEngine engine) {
    Arguments.assertNotNull("parentDialog", parentDialog);
    Arguments.assertNotNull("engine", engine);

    this.parentDialog = parentDialog;
    this.engine = engine;

    fileChooser = new FileChooser();

    encodingComboBox = new JComboBox();
    encodingAutoComboBox = new JComboBox(new String[] { resources.text("encoding_auto") });
    encodingAutoComboBox.setEnabled(false);

    encodingCardPanel = new CardPanel();
    encodingCardPanel.add(encodingComboBox);
    encodingCardPanel.add(encodingAutoComboBox);

    readerList = Components//  w w w.ja va 2s. c  om
            .list(new StaticListModel<IDictionaryReader>(new ReaderLabelBuilder(), engine.getReaders()));
    readerList.setSelectedIndex(0);

    editorPane = Components.editorPane();
    editorPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                Browser.openUrl(e.getURL().toExternalForm());
            }
        }
    });

    continueButton = Buttons.continue1();
    continueButton.setDefaultCapable(true);

    closeButton = Buttons.cancel();

    JPanel buttonPanel = new JPanel(new GridLayout(1, 2, GAP5, GAP5));
    buttonPanel.add(continueButton);
    buttonPanel.add(closeButton);

    JPanel listReaderPanel = new JPanel(new BorderLayout());
    listReaderPanel.add(resources.label("reader"), BorderLayout.NORTH);
    listReaderPanel.add(new JScrollPane(readerList), BorderLayout.CENTER);

    readerList.setPreferredSize(new Dimension(50, 50));
    listReaderPanel.setPreferredSize(new Dimension(100, 100));

    JPanel descriptionReaderPanel = new JPanel(new BorderLayout());
    descriptionReaderPanel.add(resources.label("readerDescription"), BorderLayout.NORTH);
    descriptionReaderPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listReaderPanel, descriptionReaderPanel);
    splitPane.setContinuousLayout(true);
    splitPane.setDividerLocation(130);

    gui = new JPanel(new TableLayout(new double[][] { { TableLayout.PREFERRED, GAP5, TableLayout.FILL },
            { TableLayout.FILL, // 0: reader panel
                    GAP5, TableLayout.PREFERRED, // 2: file
                    GAP5, TableLayout.PREFERRED, // 4: encoding
                    GAP5 * 2, TableLayout.PREFERRED // 6: button panel
            } }));

    gui.add(splitPane, "0, 0, 2, 0");

    gui.add(resources.label("file"), "0, 2");
    gui.add(fileChooser.getGui(), "2, 2");

    gui.add(resources.label("encoding"), "0, 4");
    gui.add(encodingCardPanel.getGui(), "2, 4");

    gui.add(buttonPanel, "0, 6, 2, 6, right, center");

    Gaps.applyBorder7(gui);

    ActionBinder.bind(this);

    if (encodingComboBox.getModel().getSize() > 0) {
        encodingComboBox.setSelectedIndex(0);
    }

    // filters
    for (IDictionaryReader reader : engine.getReaders()) {
        fileChooser.getChooser().addChoosableFileFilter(reader.getFileFilter());
    }

    onReaderSelected();
    onFileFieldEdited();
}

From source file:Output.SplitChart.java

public void createAndShowGUI() {
    //Create and set up the window.
    this.chartPanel = new ChartPanel(this.chart);
    int[] indexNull = new int[0];
    this.drawGeneratorCommitmentWithTrueCostData("", 0, 0, 0, indexNull);

    SelectPanel selectPanel = new SelectPanel(this.amesFrame, false, null, this);

    //Provide minimum sizes for the two components in the split pane
    selectPanel.setMinimumSize(new Dimension(100, 50));
    this.chartPanel.setMinimumSize(new Dimension(100, 30));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(selectPanel);
    splitPane.setRightComponent(this.chartPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(430);/*from   w w  w  .j  ava2s  .co m*/

    //Add the split pane to this frame
    this.getContentPane().add(splitPane);

    //Display the window.
    this.pack();
    this.setVisible(true);
}

From source file:com.igormaznitsa.sciareto.ui.MainFrame.java

public MainFrame(@Nonnull @MustNotContainNull final String... args) {
    super();/*from w  w  w  .  ja  va  2 s . co m*/
    initComponents();

    this.stackPanel = new JPanel();
    this.stackPanel.setFocusable(false);
    this.stackPanel.setOpaque(false);
    this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32));
    this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS));

    final JPanel glassPanel = (JPanel) this.getGlassPane();
    glassPanel.setOpaque(false);

    this.setGlassPane(glassPanel);

    glassPanel.setLayout(new BorderLayout(8, 8));
    glassPanel.add(Box.createGlue(), BorderLayout.CENTER);

    final JPanel ppanel = new JPanel(new BorderLayout(0, 0));
    ppanel.setFocusable(false);
    ppanel.setOpaque(false);
    ppanel.setCursor(null);
    ppanel.add(this.stackPanel, BorderLayout.SOUTH);

    glassPanel.add(ppanel, BorderLayout.EAST);

    this.stackPanel.add(Box.createGlue());

    glassPanel.setVisible(false);

    this.setTitle("Scia Reto");

    setIconImage(UiUtils.loadImage("logo256x256.png"));

    this.stateless = args.length > 0;

    final MainFrame theInstance = this;

    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(@Nonnull final WindowEvent e) {
            if (doClosing()) {
                dispose();
            }
        }
    });

    this.tabPane = new EditorTabPane(this);

    this.explorerTree = new ExplorerTree(this);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(250);
    splitPane.setResizeWeight(0.0d);
    splitPane.setLeftComponent(this.explorerTree);
    splitPane.setRightComponent(this.tabPane);

    add(splitPane, BorderLayout.CENTER);

    this.menuOpenRecentProject.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects();
            if (lastOpenedProjects.length > 0) {
                for (final File folder : lastOpenedProjects) {
                    final JMenuItem item = new JMenuItem(folder.getName());
                    item.setToolTipText(folder.getAbsolutePath());
                    item.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openProject(folder, false);
                        }
                    });
                    menuOpenRecentProject.add(item);
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            menuOpenRecentProject.removeAll();
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    this.menuOpenRecentFile.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles();
            if (lastOpenedFiles.length > 0) {
                for (final File file : lastOpenedFiles) {
                    final JMenuItem item = new JMenuItem(file.getName());
                    item.setToolTipText(file.getAbsolutePath());
                    item.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFileAsTab(file);
                        }
                    });
                    menuOpenRecentFile.add(item);
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            menuOpenRecentFile.removeAll();
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    if (!this.stateless) {
        restoreState();
    } else {
        boolean openedProject = false;
        for (final String filePath : args) {
            final File file = new File(filePath);
            if (file.isDirectory()) {
                openedProject = true;
                openProject(file, true);
            } else if (file.isFile()) {
                openFileAsTab(file);
            }
        }
        if (!openedProject) {
            //TODO try to hide project panel!
        }
    }

    final LookAndFeel current = UIManager.getLookAndFeel();
    final ButtonGroup lfGroup = new ButtonGroup();
    final String currentLFClassName = current.getClass().getName();
    for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName());
        lfGroup.add(menuItem);
        if (currentLFClassName.equals(info.getClassName())) {
            menuItem.setSelected(true);
        }
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(@Nonnull final ActionEvent e) {
                try {
                    UIManager.setLookAndFeel(info.getClassName());
                    SwingUtilities.updateComponentTreeUI(theInstance);
                    PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL,
                            info.getClassName());
                    PreferencesManager.getInstance().flush();
                } catch (Exception ex) {
                    LOGGER.error("Can't change LF", ex);
                }
            }
        });
        this.menuLookAndFeel.add(menuItem);
    }
}

From source file:com.excilys.ebi.gatling.recorder.ui.component.RunningFrame.java

public RunningFrame() {

    /* Initialization of the frame */
    setTitle("Gatling Recorder - Running...");
    setMinimumSize(new Dimension(800, 640));
    setLocationRelativeTo(null);/*from  ww w.jav  a2 s.  co m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    setIconImages(Commons.getIconList());

    /* Declaration & initialization of components */
    JButton btnClear = new JButton("Clear");
    final JButton btnStop = new JButton("Stop !");
    btnStop.setSize(120, 30);

    JScrollPane panelFilters = new JScrollPane(executedEvents);
    panelFilters.setPreferredSize(new Dimension(300, 100));

    stringRequest.setPreferredSize(new Dimension(330, 100));
    JSplitPane requestResponsePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(stringRequest),
            new JScrollPane(stringResponse));
    final JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, requestResponsePane, stringRequestBody);

    JScrollPane panelHostsCertificate = new JScrollPane(requiredHostsCertificate);
    panelHostsCertificate.setPreferredSize(new Dimension(300, 100));

    /* Layout */
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(10, 5, 0, 0);

    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridy = 0;
    add(new JLabel("Tag :"), gbc);

    gbc.gridx = 1;
    add(txtTag, gbc);

    gbc.gridx = 2;
    gbc.weightx = 0.5;
    add(btnTag, gbc);

    gbc.gridx = 3;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weightx = 0.25;
    add(btnClear, gbc);

    gbc.gridx = 4;
    gbc.anchor = GridBagConstraints.LINE_END;
    add(btnStop, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(new JLabel("Executed Events:"), gbc);

    gbc.gridy = 2;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;
    gbc.weighty = 0.20;
    gbc.fill = GridBagConstraints.BOTH;
    add(panelFilters, gbc);

    gbc.gridy = 4;
    gbc.weightx = 1;
    gbc.weighty = 0.75;
    gbc.fill = GridBagConstraints.BOTH;
    add(sp, gbc);

    gbc.gridy = 5;
    gbc.weighty = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.CENTER;
    add(new JLabel("Secured hosts requiring accepting a certificate:"), gbc);

    gbc.gridy = 6;
    gbc.weighty = 0.05;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(panelHostsCertificate, gbc);

    /* Listeners */
    btnTag.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!txtTag.getText().equals(EMPTY)) {
                TagEvent tag = new TagEvent(txtTag.getText());
                events.addElement(tag.toString());
                executedEvents.ensureIndexIsVisible(events.getSize() - 1);
                listEvents.add(tag);
                txtTag.setText(EMPTY);
            }
        }
    });

    executedEvents.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (executedEvents.getSelectedIndex() >= 0) {
                Object obj = listEvents.get(executedEvents.getSelectedIndex());
                if (obj instanceof ResponseReceivedEvent) {
                    ResponseReceivedEvent event = (ResponseReceivedEvent) obj;
                    stringRequest.txt.setText(event.getRequest().toString());
                    stringResponse.txt.setText(event.getResponse().toString());
                    stringRequestBody.txt.setText(new String(event.getRequest().getContent().array()));
                } else {
                    stringRequest.txt.setText(EMPTY);
                    stringResponse.txt.setText(EMPTY);
                    stringRequestBody.txt.setText(EMPTY);
                }
            }
        }
    });

    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearOldRunning();
        }
    });

    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveScenario();
            proxy.shutdown();
            proxy = null;
            if (!Configuration.getInstance().isConfigurationSkipped())
                getEventBus().post(new ShowConfigurationFrameEvent());
            else
                System.exit(0);
        }
    });
}

From source file:org.ash.history.MainPreview.java

/**
 * Load calendar and add to JSplitPane//from w  ww. ja v  a  2s . c  o  m
 * 
 * @param envDir
 */
private void loadCalendarPreview(String envDir) {

    try {

        // Create new instance of CalendarH
        CalendarH calendarH = new CalendarH(envDir, this);

        // Close preview instance of ASHDatabaseH
        if (this.ashDBPrevPeriod != null)
            this.ashDBPrevPeriod.close();
        this.ashDBPrevPeriod = calendarH.getDatabaseHistory();

        splitCalendarPreview = new JSplitPane();
        splitCalendarPreview.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        splitCalendarPreview.add(calendarH, JSplitPane.LEFT);
        splitCalendarPreview.add(new JPanel(), JSplitPane.RIGHT);
        splitCalendarPreview.setDividerLocation(splitCalendarPreviewDivLocation);
        splitCalendarPreview.setOneTouchExpandable(true);

        this.main.removeAll();

        splitMainPane = new JSplitPane();
        splitMainPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
        splitMainPane.add(splitCalendarPreview, JSplitPane.TOP);
        splitMainPane.add(new JPanel(), JSplitPane.BOTTOM);
        splitMainPane.setDividerLocation(splitMainPaneDivLocation);
        splitMainPane.setOneTouchExpandable(true);

        this.main.add(splitMainPane);
        this.validate();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:SplitPaneDemo2.java

public SplitPaneDemo() {
    //Read image names from a properties file.
    ResourceBundle imageResource;
    try {/*from   w  w  w .j  av  a  2  s .c  o  m*/
        imageResource = ResourceBundle.getBundle("imagenames");
        String imageNamesString = imageResource.getString("images");
        imageNames = parseList(imageNamesString);
    } catch (MissingResourceException e) {
        handleMissingResource(e);
    }

    //Create the list of images and put it in a scroll pane.
    list = new JList(imageNames);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    JScrollPane listScrollPane = new JScrollPane(list);

    //Set up the picture label and put it in a scroll pane.
    ImageIcon firstImage = createImageIcon("images/" + (String) imageNames.firstElement());
    if (firstImage != null) {
        picture = new JLabel(firstImage);
    } else {
        picture = new JLabel((String) imageNames.firstElement());
    }
    JScrollPane pictureScrollPane = new JScrollPane(picture);

    //Create a split pane with the two scroll panes in it.
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(150);

    //Provide minimum sizes for the two components in the split pane.
    Dimension minimumSize = new Dimension(100, 50);
    listScrollPane.setMinimumSize(minimumSize);
    pictureScrollPane.setMinimumSize(minimumSize);

    //Provide a preferred size for the split pane.
    splitPane.setPreferredSize(new Dimension(400, 200));
}

From source file:BasicDnD.java

public BasicDnD() {
    super(new BorderLayout());
    JPanel leftPanel = createVerticalBoxPanel();
    JPanel rightPanel = createVerticalBoxPanel();

    //Create a table model.
    DefaultTableModel tm = new DefaultTableModel();
    tm.addColumn("Column 0");
    tm.addColumn("Column 1");
    tm.addColumn("Column 2");
    tm.addColumn("Column 3");
    tm.addRow(new String[] { "Table 00", "Table 01", "Table 02", "Table 03" });
    tm.addRow(new String[] { "Table 10", "Table 11", "Table 12", "Table 13" });
    tm.addRow(new String[] { "Table 20", "Table 21", "Table 22", "Table 23" });
    tm.addRow(new String[] { "Table 30", "Table 31", "Table 32", "Table 33" });

    //LEFT COLUMN
    //Use the table model to create a table.
    table = new JTable(tm);
    leftPanel.add(createPanelForComponent(table, "JTable"));

    //Create a color chooser.
    colorChooser = new JColorChooser();
    leftPanel.add(createPanelForComponent(colorChooser, "JColorChooser"));

    //RIGHT COLUMN
    //Create a textfield.
    textField = new JTextField(30);
    textField.setText("Favorite foods:\nPizza, Moussaka, Pot roast");
    rightPanel.add(createPanelForComponent(textField, "JTextField"));

    //Create a scrolled text area.
    textArea = new JTextArea(5, 30);
    textArea.setText("Favorite shows:\nBuffy, Alias, Angel");
    JScrollPane scrollPane = new JScrollPane(textArea);
    rightPanel.add(createPanelForComponent(scrollPane, "JTextArea"));

    //Create a list model and a list.
    DefaultListModel listModel = new DefaultListModel();
    listModel.addElement("Martha Washington");
    listModel.addElement("Abigail Adams");
    listModel.addElement("Martha Randolph");
    listModel.addElement("Dolley Madison");
    listModel.addElement("Elizabeth Monroe");
    listModel.addElement("Louisa Adams");
    listModel.addElement("Emily Donelson");
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    JScrollPane listView = new JScrollPane(list);
    listView.setPreferredSize(new Dimension(300, 100));
    rightPanel.add(createPanelForComponent(listView, "JList"));

    //Create a tree.
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Mia Familia");
    DefaultMutableTreeNode sharon = new DefaultMutableTreeNode("Sharon");
    rootNode.add(sharon);//  ww w . ja v  a  2s  . c o m
    DefaultMutableTreeNode maya = new DefaultMutableTreeNode("Maya");
    sharon.add(maya);
    DefaultMutableTreeNode anya = new DefaultMutableTreeNode("Anya");
    sharon.add(anya);
    sharon.add(new DefaultMutableTreeNode("Bongo"));
    maya.add(new DefaultMutableTreeNode("Muffin"));
    anya.add(new DefaultMutableTreeNode("Winky"));
    DefaultTreeModel model = new DefaultTreeModel(rootNode);
    tree = new JTree(model);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    JScrollPane treeView = new JScrollPane(tree);
    treeView.setPreferredSize(new Dimension(300, 100));
    rightPanel.add(createPanelForComponent(treeView, "JTree"));

    //Create the toggle button.
    toggleDnD = new JCheckBox("Turn on Drag and Drop");
    toggleDnD.setActionCommand("toggleDnD");
    toggleDnD.addActionListener(this);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
    splitPane.setOneTouchExpandable(true);

    add(splitPane, BorderLayout.CENTER);
    add(toggleDnD, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
}

From source file:fxts.stations.ui.help.HelpPane.java

/**
 * Inits all components./*w  ww  .  j  a  v a2s  .c o m*/
 */
private void initComponents() {
    //creates history
    mHistory = new HelpContentHistory();
    //Create the text area for contents
    mTabbedPane = new JTabbedPane();

    //creates content tree
    mContentTree = new ContentTree("fxts/stations/trader/resources/help/contents.xml");
    mContentTree.addListener(this);

    //Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(mContentTree.getTree());
    mTabbedPane.addTab(mResMan.getString("IDS_HELP_CONTENTS", "Contents"), treeView);

    //xxx workaround for bug #6424509, memory leak
    JEditorPane.registerEditorKitForContentType("text/html", WeakHTMLEditorKit.class.getName());
    //creates the text area for the showing of the help.
    mHtmlPage = new JEditorPane();
    mHtmlPage.setEditable(false);
    mHtmlPage.putClientProperty("charset", "UTF-16");
    mHtmlPage.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent aEvent) {
            if (aEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                    onSelectContentByHyperlink(aEvent.getURL());
                    mHtmlPage.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                } catch (Exception e) {
                    mLogger.error("Hiperlink not processed!");
                    e.printStackTrace();
                }
            }
        }
    });
    JScrollPane scrollPane = new JScrollPane(mHtmlPage);

    //creates a split pane for the change log and the text area.
    mSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mTabbedPane, scrollPane);
    mSplitPane.setOneTouchExpandable(true);

    //Creates the toolbar area.
    JToolBar toolbar = UIManager.getInst().createToolBar();
    toolbar.setFloatable(false);

    //creates label with left arrow
    UIManager uiMan = UIManager.getInst();
    mBackButton = uiMan.createButton(null, "ID_HELP_LEFT_ARROW", "ID_HELP_LEFT_ARROW_DESC",
            "ID_HELP_LEFT_ARROW_DESC");
    mBackButton.setEnabled(false);
    mBackButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            if (mHistory.hasBackStep()) {
                mIsHistorycalStep = true;
                onSelectContent(mHistory.back());
                mBackButton.setEnabled(mHistory.hasBackStep());
                mForwardButton.setEnabled(mHistory.hasForwardStep());
            }
        }
    });
    toolbar.add(mBackButton);

    //creates label with right arrow
    mForwardButton = uiMan.createButton(null, "ID_HELP_RIGHT_ARROW", "ID_HELP_RIGHT_ARROW_DESC",
            "ID_HELP_RIGHT_ARROW_DESC");
    mForwardButton.setEnabled(false);
    mForwardButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            if (mHistory.hasForwardStep()) {
                mIsHistorycalStep = true;
                onSelectContent(mHistory.forward());
                mBackButton.setEnabled(mHistory.hasBackStep());
                mForwardButton.setEnabled(mHistory.hasForwardStep());
            }
        }
    });
    toolbar.add(mForwardButton);

    //creates label with up arrow
    mUpButton = uiMan.createButton(null, "ID_HELP_UP_ARROW", "ID_HELP_UP_ARROW_DESC", "ID_HELP_UP_ARROW_DESC");
    mUpButton.setEnabled(mContentTree.getIterator().hasPrevious());
    mUpButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            mContentsBrowsing = true;
            onSelectContent(mContentTree.getIterator().previous());
            mUpButton.setEnabled(mContentTree.getIterator().hasPrevious());
            mDownButton.setEnabled(mContentTree.getIterator().hasNext());
        }
    });
    toolbar.add(mUpButton);

    //creates label with down arrow
    mDownButton = uiMan.createButton(null, "ID_HELP_DOWN_ARROW", "ID_HELP_DOWN_ARROW_DESC",
            "ID_HELP_DOWN_ARROW_DESC");
    mDownButton.setEnabled(mContentTree.getIterator().hasNext());
    mDownButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent aEvent) {
            mContentsBrowsing = true;
            onSelectContent(mContentTree.getIterator().next());
            mUpButton.setEnabled(mContentTree.getIterator().hasPrevious());
            mDownButton.setEnabled(mContentTree.getIterator().hasNext());
        }
    });
    toolbar.add(mDownButton);

    //sets layout
    setLayout(new BorderLayout());

    //add the components to the frame.
    add(mSplitPane, BorderLayout.CENTER);
    add(toolbar, BorderLayout.NORTH);

    //sets first page
    onSelectContent(mContentTree.getIterator().toBegin());
}