File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing problem, with examples

 
Ramses Tutoli
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2937
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2937
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ramses Tutoli
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic