?
Solved

I need to set up a visible GridBagLayout with 2 JListboxes

Posted on 2005-04-19
9
Medium Priority
?
221 Views
Last Modified: 2010-03-31
GridBAgLayout should be 100 by 100 = 1000 cells.
The two Jlist boxes should be placed to-from X,Y cell starting from 0,0 which would be upper,left side.

Is this approach possible?

--
Idar
0
Comment
Question by:Idarhillgaar
  • 4
  • 3
  • 2
9 Comments
 
LVL 3

Expert Comment

by:RomanRega
ID: 13818427
i dont think i quite get what you mean.
Can you clarify it a little.
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13818495
If your cells are equal then you might want to consider GridLayout instead.
Having 1000 cells might look weird though.
You can't have the same component appear in more then once Cell.
0
 

Author Comment

by:Idarhillgaar
ID: 13818509
I want to set up a JPane with cells, then place components around inside these cells like a coordinate system.
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.

 

Author Comment

by:Idarhillgaar
ID: 13818516
I suppose 1000 cells are too much. - cell numbers can be changed though.
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13818744
As I said if you plan to have a Grid layout style then you might consider GridLayout(x,y) instead.
0
 
LVL 3

Accepted Solution

by:
RomanRega earned 2000 total points
ID: 13819648
Maybe i get what you mean.

You mean you want divide the space in tiles and then say (x,y) are "tile coords" of the upper left corner
and then width and height to say how many tiles you wish the JList to be large and tall.

I dont know if that's the best approach to the problem, but the answer is yes. It can be done.

I have not time to test this now. But i hope it can help you.

Try like this:

JPanel pane = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints( x, y, width, height, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,new Insets(0, 0, 0, 0), 0 ,0 );
pane.add(YOURJLIST, c);

Try obviosly changing the GridBagConstraints params as you wish.
For detailed explaination look:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/GridBagConstraints.html

 
0
 

Author Comment

by:Idarhillgaar
ID: 13819810
Cheers,

U mentioned it might not be the best approach? I'd very much like to know a better approach if u have one.

Thanks so far though :)
0
 
LVL 3

Expert Comment

by:RomanRega
ID: 13822256
It depends on what is your final purpose.

Try this one. If you get exacly what you want, without any performance problem... what the hell... that's your choice.

Otherwise you can always program yourself a custom layout.
Can be useful because you can use it in other projects too.
And, if you get the job right, you get exacly what you want.

GridBaglayout has the worst reputation due to its  GridBagConstraints monster. But that doesn't mean that sucks or it is useless. Give it a try and report any problem.

Sorry if i didnt answer before, but here is Italy, and time is different :)
0
 

Author Comment

by:Idarhillgaar
ID: 13834532
Cheers!

Chosed to scrap the GridBag - was too awkward to work with and I don't have the time.

Sorry I didn't reply earlier, really busy in my final year :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

850 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