File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Resizable border between text areas Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Resizable border between text areas" Watch "Resizable border between text areas" New topic
Author

Resizable border between text areas

Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
In a typical Instant Messaging chat window, there are 2 text areas - 1 on top and another on the bottom.

Usually we can freely shift the border between the 2 text areas - up and down, thus resizing the text areas. 1 will grow larger as the other grows smaller.

How can I implement this with AWT ? Some sample code would be appreciated.

Thanks a lot.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
JSplitPane
Stephen Boston
Ranch Hand

Joined: Jul 14, 2005
Posts: 165
IN your GUI constructor...



panel1 and panel2 hold different components and other panels for my project. I split the frame and added the two panel with the above code.


Steve<br /> <br />No matter where you go, there you are.<br /> <br />"My evil self is at the door, and I have no power to stop it."
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
I noticed you specified AWT, is Swing unacceptable for some reason?

If you can use Swing, then JSplitPane is the class you want and has already been mentioned. As this is an instant messaging program you most likely want a VERTICAL_SPLIT with one component on top of the other rather than a horizontal as was defined in the above post. You should also be aware of the resizeWeight property which has a value of 0.0 (defualt) to 1.0. 0.0 will assign all extra space to the right/bottom component, and if your program follows the typical form that's probably reverse of what you want. 1.0 would assign it to the top/left component (which is likely your receiving window). Also, the divider location can be set using a double to make it proportional rather than an absolute which was used in the above post.

If it must be AWT only it will be much more annoying to do.
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Michael Dunn, thanks for telling me it's a JSplitPane that I should use.

Stephen Boston, thanks for the sample code.

Ken Blair, thanks for being meticulous - realized that my question was asking for a AWT solution. This is because my current code (done half way) is in AWT. Looks like I'll have to just switch to Swing... rewriting my code. Thanks for customizing your answers to my needs (VERTICAL_SPLIT etc). Thanks for informing that "If it must be AWT only it will be much more annoying to do".

I searched the net for JSplitPane ... and landed myself on this very informative page :
http://java.sun.com/docs/books/tutorial/uiswing/components/splitpane.html

Thanks all for your time. Appreciate it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resizable border between text areas
 
Similar Threads
layout
Failed SCWCD with 60% Score
image hightlite
Difference between Jdk 1.1, Jdk 1.2 and Jdk 1.4
Another table border question