• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Resizable border between text areas

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSplitPane
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 want my playground back. Here, I'll give you this tiny ad for it:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic