1

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));


        }
Alvin Pulido
  • 49
  • 2
  • 10
  • 1
    Why a JFrame? Aren't those top-level components? Wouldn't a panel be more appropriate? – Dave Newton Feb 19 '12 at 17:22
  • Sir I tried to convert it to a Jpanel but there are some components that does not support so I used Jframe. Is there any solution for my problem? – Alvin Pulido Feb 19 '12 at 17:25
  • *"Jpanel but there are some components that does not support"* Perhaps you need a `JDesktopPane` with `JInternalFrame` instances. – Andrew Thompson Feb 19 '12 at 17:30
  • Is it possible that i can insert the internal frame inside the splitpane Sir? – Alvin Pulido Feb 19 '12 at 17:36
  • 1
    This makes no sense whatsoever. A JFrame must sit by itself. Period. If "there are some components that does not support..." then you're fixing the wrong thing. Tell us what components you mean, and then use JPanels. – Hovercraft Full Of Eels Feb 19 '12 at 18:06
  • Please start comments to me with @Andrew so I get notified. A `JInternalFrame` is added to a `JDesktopPane`. The desktop pane can be added to anything that will accept a `Container`. I suggested internal frames because they were more like a frame, but note that since you can add multiple internal frames to 1 desktop page, the split pane does not make much sense any longer. Just have 1 desktop pane instead, with any number of internal frames. (And please don't call me 'Sir'. plan 'Andrew' is fine.) – Andrew Thompson Feb 20 '12 at 02:40
  • @Andrew Ihave an update on my code, I have converted it to a JPanel but it didn't perform the function,just display. – Alvin Pulido Feb 20 '12 at 07:53
  • For better help sooner, post an [SSCCE](http://sscce.org/) (rather than uncompilable code snippets). – Andrew Thompson Feb 20 '12 at 08:42

1 Answers1

1

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

Sastrija
  • 3,284
  • 6
  • 47
  • 64
mino
  • 6,978
  • 21
  • 62
  • 75