Question

I'm making GUI using JSplitPane and I want to display a JFrame in the left side of the JSplitPane and another JFrame inside the right side of a JSplitPane. The name of the other JFrame is Minimize.java and Diagram.java. My problem is how can i call these and display it in the left and right side of the JSplitPane? An update for this post, I converted my JFrame to a JPanel and successful displayed but the problem now is it didn't perform the function/method.

Here's my code for the Main Form.

        public LogicGates()
        {
            Minimize mi = new Minimize();

             //mi.setVisible(true);
            JLabel iExp = new JLabel("Inputted Expression: ");
            p.add(iExp);
            j1= new JLabel("");
            j1.setVisible(false);
            p.add(j1);


            JScrollPane aaScrollPane = new JScrollPane(aa);

//here is my problem,when i run the code it displays the label and jcombobox but didn't perform the function
            gatessplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mi, aaScrollPane);
            gatessplit.setOneTouchExpandable(true);
            gatessplit.setDividerLocation(300);

            //Provide minimum sizes for the two components in the split pane.
            Dimension minimumSize = new Dimension(150, 80);
            //frame.setMinimumSize(minimumSize);
            aaScrollPane.setMinimumSize(minimumSize);

            //Provide a preferred size for the split pane.
            gatessplit.setPreferredSize(new Dimension(900, 500));


        }
Was it helpful?

Solution

Could you not use JPanels here combined with a Layout Manager on the JFrame?

This will allow you to create a JFrame, then add a layout to it comprising of two sections on the left and right. You can then add a JPanel to the left and right and add components to each JPanel.

JPanel tutorial: http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html

Layout tutorial: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top