Example usage for javax.swing JSplitPane JSplitPane

List of usage examples for javax.swing JSplitPane JSplitPane

Introduction

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

Prototype

@ConstructorProperties({ "orientation" })
public JSplitPane(int newOrientation) 

Source Link

Document

Creates a new JSplitPane configured with the specified orientation.

Usage

From source file:TreeIconDemo.java

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

    // Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);/*from w w w . j a va2s . co m*/

    // Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    // Set the icon for leaf nodes.
    ImageIcon leafIcon = createImageIcon("images/middle.gif");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    } else {
        System.err.println("Leaf icon missing; using default.");
    }

    // Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    // Create the scroll pane and add the tree to it.
    JScrollPane treeView = new JScrollPane(tree);

    // Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    // Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); // XXX: ignored in some releases
    // of Swing. bug 4101306
    // workaround for bug 4101306:
    // treeView.setPreferredSize(new Dimension(100, 100));

    splitPane.setPreferredSize(new Dimension(500, 300));

    // Add the split pane to this panel.
    add(splitPane);
}

From source file:components.TreeIconDemo.java

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

    //Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);/*from   w  w w  .j  a v a2s. c  o m*/

    //Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    //Set the icon for leaf nodes.
    ImageIcon leafIcon = createImageIcon("images/middle.gif");
    if (leafIcon != null) {
        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
        renderer.setLeafIcon(leafIcon);
        tree.setCellRenderer(renderer);
    } else {
        System.err.println("Leaf icon missing; using default.");
    }

    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    //Create the scroll pane and add the tree to it. 
    JScrollPane treeView = new JScrollPane(tree);

    //Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    //Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); //XXX: ignored in some releases
                                       //of Swing. bug 4101306
                                       //workaround for bug 4101306:
                                       //treeView.setPreferredSize(new Dimension(100, 100)); 

    splitPane.setPreferredSize(new Dimension(500, 300));

    //Add the split pane to this panel.
    add(splitPane);
}

From source file:components.TreeDemo.java

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

    //Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);//from ww w  .j  a va 2 s.c om

    //Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    if (playWithLineStyle) {
        System.out.println("line style = " + lineStyle);
        tree.putClientProperty("JTree.lineStyle", lineStyle);
    }

    //Create the scroll pane and add the tree to it. 
    JScrollPane treeView = new JScrollPane(tree);

    //Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    //Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100);
    splitPane.setPreferredSize(new Dimension(500, 300));

    //Add the split pane to this panel.
    add(splitPane);
}

From source file:i18nplugin.TranslatorEditor.java

private void createGui() {
    setLayout(new FormLayout("fill:min:grow", "fill:min:grow, pref"));
    CellConstraints cc = new CellConstraints();

    // Top/*from  w ww  .  ja  v  a 2  s. c o  m*/
    PanelBuilder topPanel = new PanelBuilder(new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow"));
    topPanel.setBorder(Borders.DLU4_BORDER);
    topPanel.addSeparator(mLocalizer.msg("original", "Original text"), cc.xy(1, 1));

    mOriginal = new JTextArea();
    mOriginal.setWrapStyleWord(false);
    mOriginal.setEditable(false);

    topPanel.add(new JScrollPane(mOriginal), cc.xy(1, 3));

    // Bottom
    PanelBuilder bottomPanel = new PanelBuilder(
            new FormLayout("fill:10dlu:grow", "pref, 5dlu, fill:pref:grow"));
    bottomPanel.setBorder(Borders.DLU4_BORDER);
    bottomPanel.addSeparator(mLocalizer.msg("translation", "Translation"), cc.xy(1, 1));
    mTranslation = new JTextArea();
    mTranslation.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            updateState();
        }

        public void insertUpdate(DocumentEvent e) {
            updateState();
        }

        public void removeUpdate(DocumentEvent e) {
            updateState();
        }
    });
    mOriginal.setBackground(mTranslation.getBackground());
    mOriginal.setForeground(mTranslation.getForeground());

    bottomPanel.add(new JScrollPane(mTranslation), cc.xy(1, 3));

    // Splitpane

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setBorder(null);

    split.setTopComponent(topPanel.getPanel());
    split.setBottomComponent(bottomPanel.getPanel());

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            split.setDividerLocation(0.5);
        }
    });

    add(split, cc.xy(1, 1));

    // translation state
    PanelBuilder panel = new PanelBuilder(new FormLayout("pref, 2dlu, fill:10dlu:grow", "pref, 3dlu, pref"));
    panel.setBorder(Borders.DLU4_BORDER);
    panel.addSeparator(mLocalizer.msg("state", "State"), cc.xyw(1, 1, 3));
    mIcon = new JLabel();
    panel.add(mIcon, cc.xy(1, 3));
    mState = new JLabel("-");
    panel.add(mState, cc.xy(3, 3));

    add(panel.getPanel(), cc.xy(1, 2));
}

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);/*from  ww  w  .j ava  2s . c o  m*/

    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:gui.TraitViewerDialog.java

private JPanel createControls() {
    model = new TraitTableModel();
    for (int i = 0; i < tFile.getNames().size(); i++) {
        model.addRow(new Object[] { i + 1, tFile.getEnabled().get(i), tFile.getNames().get(i) });
    }// www . ja va2 s .  c  om

    table = new JTable(model);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getColumnModel().getColumn(0).setPreferredWidth(13);
    table.getColumnModel().getColumn(1).setPreferredWidth(30);
    table.getColumnModel().getColumn(2).setPreferredWidth(130);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(this);

    splits = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splits.setLeftComponent(new JScrollPane(table));

    splits.setDividerLocation(250);
    splits.setResizeWeight(0.5);
    splits.setRightComponent(new JPanel());
    JPanel p1 = new JPanel(new BorderLayout());
    p1.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
    p1.add(splits);

    return p1;
}

From source file:TreeDemo.java

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

    //Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);// w ww  . ja  v  a  2  s  .com

    //Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    if (playWithLineStyle) {
        System.out.println("line style = " + lineStyle);
        tree.putClientProperty("JTree.lineStyle", lineStyle);
    }

    //Create the scroll pane and add the tree to it. 
    JScrollPane treeView = new JScrollPane(tree);

    //Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    //Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); //XXX: ignored in some releases
                                       //of Swing. bug 4101306
                                       //workaround for bug 4101306:
                                       //treeView.setPreferredSize(new Dimension(100, 100)); 

    splitPane.setPreferredSize(new Dimension(500, 300));

    //Add the split pane to this panel.
    add(splitPane);
}

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 ww  .  j av a2  s  .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));
    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:TreeIconDemo2.java

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

    //Create the nodes.
    DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series");
    createNodes(top);//from   w  w w  . j a va 2  s.  co m

    //Create a tree that allows one selection at a time.
    tree = new JTree(top);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    //Enable tool tips.
    ToolTipManager.sharedInstance().registerComponent(tree);

    //Set the icon for leaf nodes.
    ImageIcon tutorialIcon = createImageIcon("images/middle.gif");
    if (tutorialIcon != null) {
        tree.setCellRenderer(new MyRenderer(tutorialIcon));
    } else {
        System.err.println("Tutorial icon missing; using default.");
    }

    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    //Create the scroll pane and add the tree to it. 
    JScrollPane treeView = new JScrollPane(tree);

    //Create the HTML viewing pane.
    htmlPane = new JEditorPane();
    htmlPane.setEditable(false);
    initHelp();
    JScrollPane htmlView = new JScrollPane(htmlPane);

    //Add the scroll panes to a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setTopComponent(treeView);
    splitPane.setBottomComponent(htmlView);

    Dimension minimumSize = new Dimension(100, 50);
    htmlView.setMinimumSize(minimumSize);
    treeView.setMinimumSize(minimumSize);
    splitPane.setDividerLocation(100); //XXX: ignored in some releases
                                       //of Swing. bug 4101306
                                       //workaround for bug 4101306:
                                       //treeView.setPreferredSize(new Dimension(100, 100)); 

    splitPane.setPreferredSize(new Dimension(500, 300));

    //Add the split pane to this panel.
    add(splitPane);
}