3

I need to hide the Slit Pane in my code as shown in below images. I don't know how to make split-pane hide/unhide in Java Swing base GUI. In my code I divide split pane into two horizontal parts, and then after that I divide right component of splitpane into two vertical parts. I want to hide/unhide left part of split pane.

enter image description here

enter image description here

import java.awt.*;
import java.awt.Event.*;
import javax.swing.*;

class DemoSwingDesign extends JFrame {

    boolean b = false;
    public static JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    public static JSplitPane splitpane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);

    public DemoSwingDesign() {
        JFrame frame = new JFrame("Split Pain");
        frame.setSize(300, 300);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setDefaultLookAndFeelDecorated(true);
        frame.setLayout(new GridLayout());
        //Defining Split Pane


        //splitpane size
        splitpane.setDividerLocation(150);
        splitpane1.setDividerLocation(90);
        splitpane.setContinuousLayout(true);
        splitpane.setOneTouchExpandable(true);

        JTabbedPane jtp = new JTabbedPane();
        jtp.setName("XRay");

        JTabbedPane jtp1 = new JTabbedPane();
        JTabbedPane jtp2 = new JTabbedPane();
        jtp1.setName("Set");
        jtp2.setName("OK");

        JPanel jp = new JPanel(new BorderLayout());

        JComponent Lefttabbedpane = new JTabbedPane();
        jp.add(jtp, -1);
        Lefttabbedpane = jtp;
        splitpane.add(splitpane1, "right");

        splitpane.setLeftComponent(new JScrollPane(jtp2));
        splitpane1.setTopComponent(new JScrollPane(jtp1));
        splitpane1.setBottomComponent(new JScrollPane(Lefttabbedpane));
        frame.add(splitpane);
        frame.setVisible(true);
    }
}

class Temp {

    public static void main(String args[]) {
        DemoSwingDesign d = new DemoSwingDesign();
    }
}
Jony
  • 1,035
  • 7
  • 17
  • 43
  • take a look at this link http://stackoverflow.com/questions/6836164/jsplitpane-is-there-a-way-to-show-hide-one-of-the-panes http://stackoverflow.com/questions/4934499/how-to-set-jsplitpane-divider-collapse-expand-state – Nag Mar 12 '12 at 05:49

1 Answers1

1

May be you are looking for this: JSplitPane.setOneTouchExpandable(boolean)

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
  • well that functionality i Know i want to some how exactly hide the split pane like it is shown in above image and allow that split-pane to pin and unpin as per requirement – Jony Mar 12 '12 at 05:59
  • Doesn't this does the same, hide whole part in jsplitpane. The only difference I can see is *the stylish button* in your image for this purpose. – Harry Joy Mar 12 '12 at 06:03