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 / January 2005

Tip: Looking for answers? Try searching our database.

JGoodies help needed

Thread view: 
rick333 - 02 Jan 2005 19:00 GMT
I'm using JGoodies Forms and Looks and I'm generally am very happy with
it. I have one nagging problem, however, that crops up in a lot of
places in my app.

Basically, the problem is in the use of a subsidiary JPanel used within
a main JPanel. I use FormLayout and PanelBuilder to create both
JPanels. In the following example, the subsidiary panel is called,
MyTablePanel, that uses the following layout code to layout a JTable on
the left and a button stack on the right.

FormLayout layout = new FormLayout(
"fill:max(p;100dlu):grow, 7dlu, p",
"fill:max(p;40dlu):grow");

PanelBuilder builder = new PanelBuilder(this, layout);
builder.setBorder(Borders.EMPTY_BORDER);

// Fill the panel with labels and components.
CellConstraints cc = new CellConstraints();

// Create/add a JTable on the left side of the panel
JTable myJTable = new JTable();
JScrollPane scroller = new JScrollPane(myJTable);
builder.add(scroller,         cc.xy(1, 1));

// Create/add a button stack to the right side of the panel
ButtonStackBuilder bb = new ButtonStackBuilder();
bb.addGridded(addButton);
bb.addRelatedGap();
bb.addGridded(editButton);
bb.addUnrelatedGap();
bb.addGridded(removeButton);
builder.add(bb.getPanel(), cc.xy(3, 1));

I then create a main JPanel that incorporates a few components
including the subsidiary JPanel, MyTablePanel. I use the following code
to layout the main JPanel to place MyTablePanel on top, a JLabel and
JTextArea below, followed by another JLabel and JTextArea below that:

FormLayout layout = new FormLayout(
"fill:p:grow",
"fill:max(p;50dlu):grow, 3dlu, p, 3dlu,
fill:max(p;50dlu):grow, 3dlu, p, 3dlu, fill:max(p;50dlu):grow");

PanelBuilder builder = new PanelBuilder(this, layout);
builder.setBorder(Borders.EMPTY_BORDER);
CellConstraints cc = new CellConstraints();

// Add the subsidiary JPanel
MyTablePanel myTablePanel = new MyTablePanel();
add(myTablePanel,        cc.xy(1, 1));
// Add a label and JTextArea
add(new JLabel("Natural Language"), cc.xy(1, 3));
JTextArea natLangFld = new JTextArea();
JScrollPane natLangScroller = new JScrollPane(natLangFld);
add(natLangScroller,        cc.xy(1, 5));
// Add another label and JTextArea
add(new JLabel("Programming Code"), cc.xy(1, 7));
JTextArea codeFld = new JTextArea();
JScrollPane codeScroller = new JScrollPane(codeFld);
add(codeScroller,           cc.xy(1, 9));

If I run the subsidiary JPanel standalone in a JFrame, it I can resize
width-wise with no problem. I can expand the window using mouse-drag on
the JFrame edge and contract it -- the JTable expands and contracts,
leaving room to display the JButton stack.

**** PROBLEM *****

If I run the main JPanel standalone in a JFrame, it displays correctly
upon startup, and expands correctly. The subsidiary JPanel and the two
JTextArea instances in the main JPanel expand as I expand the window,
leaving room for the subsidiary JPanel's button stack. However, if I
then reduce the window's width (again, by mouse-dragging on the JFrame
edge), the 2 JTextAreaS contract width-wise, but the JTable (inside the
subsidiary JPanel) does not contract, leaving it cut-off by the right
side of the JFrame window. The button stack in the subsidiary JPanel is
cut-off from view, as well, of course.

I don't want to combine this into one big JPanel with a single
FormLayout because I reuse the subsidiary JPanel in several other
higher level JPanels. In addition, this is but one of many instances of
using this type of hierarchical gui structure in my application, so
doing so would seriously degrade my application architecture and
supportability.

If anyone can help me solve this problem, I would be very much
indebted.

Thank you,

Rick
Karsten Lentzsch - 03 Jan 2005 20:06 GMT
> **** PROBLEM *****
>
> [...] However, if I
> then reduce the window's width (again, by mouse-dragging on the JFrame
> edge), the 2 JTextAreaS contract width-wise, but the JTable (inside the
> subsidiary JPanel) does not contract, [...]

See the Forms FAQ 3.6 that ships with the Forms 1.0.5.
Also see the new pitfalls section in the Forms tutorial.

Likely its the JTextArea and its (re)-sizing behavior
that nags you. If you can't get it to work without
further help, please post a stripped example with
just the JTextArea and simpler 'rests' to the Forms
user mailing list: users at forms.dev.java.net

Hope this helps. Best regards,
Karsten Lentzsch
Andrew Thompson - 04 Jan 2005 11:42 GMT
> If you can't get it to work without
> further help, please post a stripped example with
> just the JTextArea and simpler 'rests' to the Forms
> user mailing list: users at forms.dev.java.net

Sounds just like an SSCCE.
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

rick333 - 05 Jan 2005 00:49 GMT
Thanks...it was a JTextArea resize problem. I wasn't aware of the
forms.dev.java.net site. I read 3.6 of the FAQ and solved my problem. I
really appreciate your help and your forms and looks libraries.


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.