Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2005

Tip: Looking for answers? Try searching our database.

nesting JSplitPane's..

Thread view: 
Frances - 31 Aug 2005 22:47 GMT
pls, is this right way to nest JSplitPane's??

scrollTop = new JScrollPane(TextAreaTop,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   
    scrollBottom = new JScrollPane(TextAreaBottom,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   
    splitP = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollTop,
scrollBottom);

   
     scrollLeft = new JScrollPane(splitP,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   
    scrollRight = new JScrollPane(TextAreaRight);
   
    splitP2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollLeft,
scrollRight);

I tied to follow what's here..
http://java.sun.com/docs/books/tutorial/uiswing/components/splitpane.html#nesting

only I noticed one of SplitPane's in this example is in a separate
class (diff. file..) I want everything together, I hope this is ok..
I think I have basic syntax ok (compiles fine), however I get an extra
ScrollPane to the left of right element in right SplitPane (yikes..)
but splitP2 should be the left SplitPane (splitP..  w/two TextAreas..
TextAreaTop and TextAreaBottom) and that one TextArea on the right
(TextAreaRight..) this is what I get, however...
http://www.francesdelrio.com/pane.gif

(main thing I also need to do is how to lay it out so when user resizes
window elements continue to fill window (like a standard IM window..)
thank you very much..  Frances
Andrey Kuznetsov - 31 Aug 2005 23:45 GMT
> pls, is this right way to nest JSplitPane's??

right way is not to nest but use SplitPane which can be splitted
unifinitely.
There are many implementation, for example JideSplitPane (jidesoft.com) or
GSplitPane (jgui.imagero.com).
GSplitPane has the advantage that it can be used with both Swing and AWT
(99% code are the same for heavy- and lightweight version!).

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Thomas Hawtin - 01 Sep 2005 00:04 GMT
> scrollTop = new JScrollPane(TextAreaTop,
> ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
[quoted text clipped - 11 lines]
> ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
>     ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

This scroll pane is a bit pointless. You really don't want one scrolling
area within another.

I'm a bit confused about the border in your gif. I would expect it to go
right around the horizontal split pane.

>     scrollRight = new JScrollPane(TextAreaRight);
>    
>     splitP2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollLeft,
> scrollRight);

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Michael Dunn - 01 Sep 2005 01:50 GMT
> pls, is this right way to nest JSplitPane's??
>
> <snip>

try this

import javax.swing.*;
import java.awt.*;
class Testing extends JFrame
{
 public Testing()
 {
   setSize(600,400);
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   setLocation(300,100);
   JTextArea textAreaTop = new JTextArea();
   JScrollPane scrollTop = new JScrollPane(textAreaTop,22,31);
   JTextArea textAreaBottom = new JTextArea();
   JScrollPane scrollBottom = new JScrollPane(textAreaBottom,22,31);
   JSplitPane splitP = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
scrollTop,scrollBottom);
   splitP.setResizeWeight(0.5);
   JTextArea textAreaRight = new JTextArea();
   JScrollPane scrollRight = new JScrollPane(textAreaRight);
   JSplitPane splitP2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
splitP,scrollRight);
   splitP2.setResizeWeight(0.5);
   getContentPane().add(splitP2);
 }
 public static void main( String args[] ){new
Testing().setVisible(true);}
}
Frances - 01 Sep 2005 02:27 GMT
>>pls, is this right way to nest JSplitPane's??
>>
[quoted text clipped - 28 lines]
> Testing().setVisible(true);}
> }

this is great!!!   thank you!!  :)

main thing you achieved for me is everything resizes if window is
resized (i.e., all elements always fill screen..  what code is it that
does this?  (also, 'public Testing'.. is this an inner class?)

thank you so much..:)  Frances
Michael Dunn - 01 Sep 2005 02:40 GMT
> all elements always fill screen..  what code is it that does this?

.setResizeWeight(0.5);

> 'public Testing'.. is this an inner class?

a constructor
Frances - 01 Sep 2005 03:24 GMT
>>all elements always fill screen..  what code is it that does this?
>
[quoted text clipped - 3 lines]
>
> a constructor

again, Michael, thank you so much..  I'm afraid I have one more little
problem.. and that is that these need to be JTextPane's.. not
JTextArea's.. (b/c I need diff. font colors in them that change
according to user input..)  so changed JTextArea's to JTextPane's and
now all three are tiny...   i.e, now that content of this

 JScrollPane scrollBottom = new JScrollPane(TPbottom,22,31);

is a JTextPane and not a JTextArea the size (22,31) is not being
respected.. I looked at constructors for JTextPane, no provision for
setting sizes, how do you set sizes for JTextPane's?  oh gees...

again, thank you very much...  Frances
Frances - 01 Sep 2005 03:27 GMT
>>> all elements always fill screen..  what code is it that does this?
>>
[quoted text clipped - 15 lines]
> respected.. I looked at constructors for JTextPane, no provision for
> setting sizes, how do you set sizes for JTextPane's?  

setSize() is ignored...  I have not been able to get setSize() method to
work for anything I have tried it on.. (JTextAreas, JTextPane's,
JButtons, whatever..)

again many thanks.............
Michael Dunn - 01 Sep 2005 03:53 GMT
In the posted code I changed JTextArea to JTextPane
and the display was identical  (java 1.4.0_01)

> JScrollPane scrollBottom = new JScrollPane(TPbottom,22,31);

here -  22,31 are not sizes, they are the numerical values of the
scrollpane constants
Frances - 01 Sep 2005 04:08 GMT
> In the posted code I changed JTextArea to JTextPane
> and the display was identical  (java 1.4.0_01)
[quoted text clipped - 3 lines]
> here -  22,31 are not sizes, they are the numerical values of the
> scrollpane constants

my gosh -- you're right.. now I have to find out what I'm doing wrong in
mine..  again many thanks..  your help is very much appreciaed...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.