Solved

Size of components in CardLayout

Posted on 1997-05-12
3
383 Views
Last Modified: 2006-11-17
I have several containers held by a CardLayout. Each of those contains a component the layout of which depends on its size. I have two problems:

1.
All containers except the one initially showed claims their width is 0, even when they are switched to later on, that is,  showed in the CardLayout. Therefore the component spoken of doesn’t lay out itself properly in those containers.

2.
I don’t really know which method to overload to make it tell the component to reorganize its layout when the main container (the entire applet in my case) is resized. Is it resize()? Validate()?

Can anyone help me out?
0
Comment
Question by:d95-mae
[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
3 Comments
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220388
Not an answer, just an alternative.

I used to encounter the kind of problems you described (and others) all over the place.

You might want to look at LAVA at:

http://www.cs.nott.ac.uk/~dsp/lava/

It is a GUI designer (that needs JDK 1.1 to run) that generates AWT layout code (compatible with both 1.0 and 1.1). Amongst its options, it allows you to define your components as percentages of a larger component.

Solves all kinds of headaches.

Now regarding your specific problem, could you post your init method, or wherever it is that you are defining your GUI to help in solbving your problem?

My initial though is that you are using fixed values instead of percentages of screen, which can cause the behaviour you are describing.
0
 
LVL 1

Expert Comment

by:mlimotte
ID: 1220389
I don't know if this will help, but here it is.

I believe the width and size are determined after the component is added.  So, if you need to test the width and size you might want to override the addNotify() method and do it there.

0
 

Accepted Solution

by:
stefanoq earned 50 total points
ID: 1220390
Use validate not addNotify.  Any time you make a change to a Component on a container whose geometry is managed you must call the verify method to cause the layout managers to recompute its display.  I have found that it is safest to call verify on the component itself;  containing components with layout managers are notified.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tomcat: Unable to run tomcat service. 2 30
maven module vs maven project 3 74
How to configure empty element in XML Document parser? 15 45
passing enum to a method 4 36
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

730 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