File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Swing problem, with examples Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Swing problem, with examples" Watch "Swing problem, with examples" New topic
Author

Swing problem, with examples

Ramses Tutoli
Greenhorn

Joined: Sep 05, 2003
Posts: 26
Here is a picture of my GUI when it first opens up:

everything is good. however, here's what happens when I resize it a bit smaller from the bottom:

the search pane components are missing and part of the book button is obscured.
now when I make things even smaller everything is obscured but the table:

the JFrame uses a BorderLayout. What can I do to fix this problem? I've looked at ComponentListener to resize the window whenever someone wants to make it too small, but this seems like a hack.
[ September 10, 2003: Message edited by: Ramses Tutoli ]
[ September 10, 2003: Message edited by: Ramses Tutoli ]
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Your "Contractors" panel should have a LayoutManager, too. Set it to, say, BorderLayout, and your JScrollPane that holds JTable should have the "center" spot in the "Contractors" panel layout manager.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Or set the size of the window, and don't let the users resize the screen. That's what I did, still got 24/24 on GUI.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Oh and two things.
First does the Book button make a screen pop up for the user to enter the customer number?
But mainly, I'd switch the Search and the JTable around. The search (combos and search button) first at the top, then the JTable underneath it, then the Book button at the bottom.
Just like a person reads top to bottom, left to right (sure some go right to left, but Sun is in the US, so its US standards. ), a GUI should work the same, it is simpler and easier to handle from a user point of view.
Mark
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
Or set the size of the window, and don't let the users resize the screen. That's what I did, still got 24/24 on GUI.
I think it is safe to say that you got lucky, Mark. I've never seen a good quality Java apps that would not allow you to resize the frame.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Another suggestion: try putting the Location JComboBox (and JLabel) below the Name, rather than to the right. Your current setup is basically forcing the minimum width to be bigger than it needs to be. Once your window does below that minimum, that's wht creates problems.
The problem with having a single JScrollPane around everything is that when you've got an outer scroll pane and one or more inner scroll pane, the outer one may kick in too soon, when you really want the inner panes (esp. the JTable's scroll pane) to handle most of the load. When you've got scrollpanes inside scrollpanes, things get more complex, and "who's in charge" depends a lot on which layout manager you're using; I find it too much of a pain to deal with. Though to be fair, that may just be because I never spent enough time working at mastering the technique; I just avoid nesting scrollpanes.


"I'm not back." - Bill Harding, Twister
Ramses Tutoli
Greenhorn

Joined: Sep 05, 2003
Posts: 26
Some good advice here. I opted to go with my plan to put a scrollpane around the frame, however. Here's how it looks now (shrunken down a bit):

here's how it looks when it's resized:

I like this solution better than preventing them from resizing at all or using ComponentListener to force a minimum height and width because i want the user to have more choice in choosing the display size he wants. If I explain my design decision in this way, I won't get docked any points if the reviewer doesn't agree with my choice, will I?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

You know what, I think the new way is very pretty. I like the look of the screen, and I think the scrollbars look good if the screen is shrunk. I have seen that in many production commercial applications on the market.
I don't think you'd lose points in that area.
Mark
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Yeah, it does seem decent. As long as the table's scroller kicks in before the outer scroller, all is well. Guess I was traumatized by a bad experience with this; need to experiment more.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing problem, with examples
 
Similar Threads
Pirates of the Carribean - the Interceptor
Scroll around main JFrame?
[medium]Challenge the mathematicians
Which OS are you?
Which OS are you?