Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how do I define absolute size and location for a layout?

Posted on 2002-03-09
6
Medium Priority
?
294 Views
Last Modified: 2012-05-04
I'm writing a card game in java, and I have a problem with the GUI: I defined several JPanels on the JFrame, for the card "hands", and used GridBagLayout. Whenever I add a card to the "hand", the whole dimensions of the panel change, and the whole layout changes as well.

How do I set the layout, the parameters, or anything else to define that the dimensions are absolute?
0
Comment
Question by:maor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 3

Expert Comment

by:daitt
ID: 6853900
Using correct layouts and constrains will help you. It depends on your GUI design. Can you describe it here, i.e. draw the layout of your panel?
By the way, setLayout(null) will set the layout to absolute. Then use setBounds(..) to set the location and size of the components.
0
 

Author Comment

by:maor
ID: 6870601
imagine a 6*6 grid. the 6 left squares are a panel, the 6 next to them are a panel, the 6 right squares are a panel, the 6 next to them are a panel. we're left with an area 3 squares wide, 6 squares high. the top 3 are a panel, the 3 below them are a panel. the bottom 3 are a panel, the 3 above are a panel. we're left with a 3*2 area, in which are a couple of other things. let me try and draw it:
 ___  ___  __________________  ___  ___
|   ||   ||                  ||   ||   |
|   ||   ||__________________||   ||   |
|   ||   | __________________ |   ||   |
|   ||   ||                  ||   ||   |
|   ||   ||__________________||   ||   |
|   ||   |                    |   ||   |
|   ||   |                    |   ||   |
|   ||   |                    |   ||   |
|   ||   | __________________ |   ||   |
|   ||   ||                  ||   ||   |
|   ||   ||__________________||   ||   |
|   ||   | __________________ |   ||   |
|   ||   ||                  ||   ||   |
|___||___||__________________||___||___|

did this help to explain things?








0
 

Author Comment

by:maor
ID: 6870602
naturally, ascii art has no place in experts-exchange :)

so try using a bit of imagination here... :)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Accepted Solution

by:
daitt earned 200 total points
ID: 6870618
I can copy and paste into notepad and imagine your layout.
I'm in a hurry now I cannot test my idea, but try this:
You have three columns GridBagLayout: (2 left panels),(middle panels and areas), (2 right panels).
Use GridLayout to arrange 2 left panels, and another gridlayout to arrange 2 right panels.
Use GridLayout (3 rows) for the middle area: (2 top rows), (middle area), (2 bottom rows).
Use some other GridLayouts for the squares.
Gotta go. Goodluck
0
 

Author Comment

by:maor
ID: 6871864
I'll give both ideas - gridlayouts and setlayout(null) - a try.
however, I still suspect I might have some trouble when adding a card to one of the gridlayouts. any thoughts on how this can be solved?
0
 

Author Comment

by:maor
ID: 7770287
It has been ages since this question went up, and this answer didn't work well.  I have decided to give up on this layout, and switched to a simpler one.
However, breaking this down into panels inside panels inside panels, has provided a partial solution, and it has made my life easier with the new layout.

sorry it took so long, enjoy the points, and thanks :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question