tags:

views:

208

answers:

1

I am developing a java desktop application. I have some doubts or problems in designing one thing which is as follows:

I want to break the the main frame

JFrame mainFrame = new JFrame("Demo");

into two parts (divided vertically) so that user can change their size by dragging the common boundary of both the parts to either left or right so that when the width of one part increases, the width of other part decreases so the size of the mainFrame remains same.

I am designing this GUI through Netbeans IDE so it is not necessary to suggest me the code. You can simply suggest me the "item" from the palette window that I can drag and drop to my mainFrame.

+7  A: 

You want a JSplitPane:

JSplitPane is used to divide two (and only two) Components. The two Components are graphically divided based on the look and feel implementation, and the two Components can then be interactively resized by the user.

Joey
When I drag the JSplitPane from the "Palette Window" of Netbeans, two button appears (named as leftbutton and rightbutton) and when I put them onto a panel they remains same... ????
Yatendra Goel
And when we drag the boundary between those two buttons, then the desired result occurs for those two buttons. I want the same result for two panels...
Yatendra Goel
Then put panels in there. I only used Netbeans for like 5 minutes before deciding that Swing is painful to write by hand but even worse with a visual designer, so I have no idea why it puts *buttons* there of all things. But you should easily be able to replace them with panels.
Joey
could you please look at one more problem at http://stackoverflow.com/questions/2070428/org-jdesktop-application-package-doesnt-exist
Yatendra Goel
I could but I have no idea on that one. Having hacked together a few Swing GUIs doesn't exactly qualify me to know about Netbeans or Java compilation problems :-)
Joey
Those "buttons" are really just place holders for you to put something in. For example, you can drag a JPanel onto each button. If you have the Inspector window open in the lower left corner of the IDE, you can see the items actually contained in the JSplitPane.
clartaq