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

public JSplitPane() 

Source Link

Document

Creates a new JSplitPane configured to arrange the child components side-by-side horizontally, using two buttons for the components.

Usage

From source file:SwingSplitSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JSplitPane Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    frame.getContentPane().add(splitPane, BorderLayout.CENTER);
    frame.setSize(300, 200);//from  w w  w . j  a va 2s  .  c  o  m
    frame.setVisible(true);
}

From source file:SplitPaneSample.java

public static void main(String args[]) {
    JFrame vFrame = new JFrame("JSplitPane Sample");
    vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JSplitPane vSplitPane = new JSplitPane();
    vSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    vFrame.getContentPane().add(vSplitPane, BorderLayout.CENTER);
    vFrame.setSize(300, 150);/*from w  w w. j  ava2 s .co m*/
    vFrame.setVisible(true);

    JFrame hFrame = new JFrame("JSplitPane Sample");
    JSplitPane hSplitPane = new JSplitPane();
    hFrame.getContentPane().add(hSplitPane, BorderLayout.CENTER);
    hFrame.setSize(300, 150);
    hFrame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setUI(new MetalTabbedPaneUI() {
        @Override/*from  w w  w.  jav a  2 s .com*/
        protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
            int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
            int extra = tabIndex * 50;
            return width + extra;
        }
    });
    tabbedPane.addTab("JTable", new JScrollPane(new JTable(5, 5)));
    tabbedPane.addTab("JTree", new JScrollPane(new JTree()));
    tabbedPane.addTab("JSplitPane", new JSplitPane());

    JPanel p = new JPanel();
    p.add(tabbedPane);

    JFrame frame = new JFrame();
    frame.setContentPane(p);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public JComponent makeUI() {
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    tabbedPane.setUI(new javax.swing.plaf.basic.BasicTabbedPaneUI() {
        @Override/*from  w  w w  . ja  va2  s  . c  o  m*/
        protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
            return 32;
        }

        @Override
        protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex,
                Rectangle iconRect, Rectangle textRect) {
            if (tabIndex == 0) {
                rects[tabIndex].height = 30 + 1;
                rects[tabIndex].y = 32 - rects[tabIndex].height + 1;
            } else if (tabIndex == 1) {
                rects[tabIndex].height = 26 + 1;
                rects[tabIndex].y = 32 - rects[tabIndex].height + 1;
            }
            super.paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect);
        }
    });
    tabbedPane.addTab("000", new JLabel("ok"));
    tabbedPane.addTab("111", new JScrollPane(new JTable()));
    tabbedPane.addTab("222", new JSplitPane());

    return tabbedPane;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopSplitPanel.java

public DesktopSplitPanel() {
    impl = new JSplitPane() {
        @Override// w  ww .jav  a2 s .  c o  m
        public void paint(Graphics g) {
            super.paint(g);

            if (applyNewPosition) {
                double ratio = position / 100.0;

                impl.setDividerLocation(ratio);
                impl.setResizeWeight(ratio);
                applyNewPosition = false;
            }
        }
    };

    // default orientation as web split
    impl.setOrientation(JSplitPane.VERTICAL_SPLIT);

    impl.setUI(new SynthSplitPaneUI() {
        @Override
        protected void dragDividerTo(int location) {
            super.dragDividerTo(location);

            // user touched split divider
            positionChanged = true;
        }
    });

    impl.setLeftComponent(new JPanel());
    impl.setRightComponent(new JPanel());

    impl.getLeftComponent().setMinimumSize(new Dimension());
    impl.getRightComponent().setMinimumSize(new Dimension());
}

From source file:hu.bme.mit.sette.snippetbrowser.SnippetBrowser.java

/**
 * Initialise the contents of the frame.
 *//*from w ww . jav a2  s .  c o  m*/
private void initialize() {
    setTitle("Snippet Browser");
    this.setBounds(50, 50, 1000, 600);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setResizeWeight(0.3);
    getContentPane().add(splitPane, BorderLayout.CENTER);

    JScrollPane scrollPaneLeft = new JScrollPane();
    splitPane.setLeftComponent(scrollPaneLeft);

    treeSnippets = new JTree();
    scrollPaneLeft.setViewportView(treeSnippets);

    JScrollPane scrollPaneRight = new JScrollPane();
    splitPane.setRightComponent(scrollPaneRight);

    txtrInfo = new JTextArea();
    txtrInfo.setEditable(false);
    scrollPaneRight.setViewportView(txtrInfo);
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanReportMain.java

private JSplitPane getJSplitPane() {

    if (jSplitPaneMain == null) {
        jSplitPaneMain = new JSplitPane();
        jSplitPaneMain.setDividerLocation(200);
        jSplitPaneMain.setLeftComponent(getJPanelExplorer());
        jSplitPaneMain.setRightComponent(getJPanBOM());
        jSplitPaneMain.setDividerSize(5);
        jSplitPaneMain.setBorder(null);/*from   ww  w . j  av a 2 s .c om*/
    }

    return jSplitPaneMain;
}

From source file:org.ash.history.detail.DetailsPanelH.java

/**
 * Initialize DetailFrame//from   ww w.  java2  s  .  co  m
 */
private void initialize() {

    this.setLayout(new BorderLayout());
    JSplitPane splitPaneMainDetail = new JSplitPane();

    this.cpuRadioButton.setText(Options.getInstance().getResource("cpuLabel.text"));
    this.cpuRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.cpuRadioButton);
    this.schedulerRadioButton.setText(Options.getInstance().getResource("schedulerLabel.text"));
    this.schedulerRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.schedulerRadioButton);
    this.userIORadioButton.setText(Options.getInstance().getResource("userIOLabel.text"));
    this.userIORadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.userIORadioButton);
    this.systemIORadioButton.setText(Options.getInstance().getResource("systemIOLabel.text"));
    this.systemIORadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.systemIORadioButton);
    this.concurrencyRadioButton.setText(Options.getInstance().getResource("concurrencyLabel.text"));
    this.concurrencyRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.concurrencyRadioButton);
    this.applicationRadioButton.setText(Options.getInstance().getResource("applicationsLabel.text"));
    this.applicationRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.applicationRadioButton);
    this.commitRadioButton.setText(Options.getInstance().getResource("commitLabel.text"));
    this.commitRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.commitRadioButton);
    this.configurationRadioButton.setText(Options.getInstance().getResource("configurationLabel.text"));
    this.configurationRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.configurationRadioButton);
    this.administrativeRadioButton.setText(Options.getInstance().getResource("administrativeLabel.text"));
    this.administrativeRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.administrativeRadioButton);
    this.networkRadioButton.setText(Options.getInstance().getResource("networkLabel.text"));
    this.networkRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.networkRadioButton);
    this.queuningRadioButton.setText(Options.getInstance().getResource("queueningLabel.text"));
    this.queuningRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.queuningRadioButton);
    this.clusterRadioButton.setText(Options.getInstance().getResource("clusterLabel.text"));
    this.clusterRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.clusterRadioButton);
    this.otherRadioButton.setText(Options.getInstance().getResource("otherLabel.text"));
    this.otherRadioButton.addItemListener(new SelectItemListenerRadioButton());
    this.setFont(this.otherRadioButton);

    this.buttonGroup.add(cpuRadioButton);
    this.buttonGroup.add(schedulerRadioButton);
    this.buttonGroup.add(userIORadioButton);
    this.buttonGroup.add(systemIORadioButton);
    this.buttonGroup.add(concurrencyRadioButton);
    this.buttonGroup.add(applicationRadioButton);
    this.buttonGroup.add(commitRadioButton);
    this.buttonGroup.add(configurationRadioButton);
    this.buttonGroup.add(administrativeRadioButton);
    this.buttonGroup.add(networkRadioButton);
    this.buttonGroup.add(queuningRadioButton);
    this.buttonGroup.add(clusterRadioButton);
    this.buttonGroup.add(otherRadioButton);

    /** Button panel fot buttons */
    this.buttonPanel = new JToolBar("PanelButton");
    this.buttonPanel.setFloatable(false);
    this.buttonPanel.setBorder(new EtchedBorder());

    this.buttonPanel.add(this.cpuRadioButton);
    this.buttonPanel.add(this.schedulerRadioButton);
    this.buttonPanel.add(this.userIORadioButton);
    this.buttonPanel.add(this.systemIORadioButton);
    this.buttonPanel.add(this.concurrencyRadioButton);
    this.buttonPanel.add(this.applicationRadioButton);
    this.buttonPanel.add(this.commitRadioButton);
    this.buttonPanel.add(this.configurationRadioButton);
    this.buttonPanel.add(this.administrativeRadioButton);
    this.buttonPanel.add(this.networkRadioButton);
    this.buttonPanel.add(this.queuningRadioButton);
    this.buttonPanel.add(this.clusterRadioButton);
    this.buttonPanel.add(this.otherRadioButton);

    splitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPaneMainDetail.add(new JPanel(), "top");
    splitPaneMainDetail.add(new JPanel(), "bottom");
    splitPaneMainDetail.setDividerLocation(230);
    splitPaneMainDetail.setOneTouchExpandable(true);

    this.mainPanel = new JPanel();
    this.mainPanel.setLayout(new BorderLayout());
    this.mainPanel.setVisible(true);
    this.mainPanel.add(splitPaneMainDetail, BorderLayout.CENTER);

    this.add(this.buttonPanel, BorderLayout.NORTH);
    this.add(this.mainPanel, BorderLayout.CENTER);
}