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.
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
posted
0
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
posted
0
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".