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

x
?
Solved

Card Layout Perfomance.

Posted on 2002-07-11
8
Medium Priority
?
329 Views
Last Modified: 2010-03-31
hi,
i'm using card layout to design my interface, each card will contain a panel where this panel will include other component such as textfield, button, check box etc.

My question is, is there any performance issue if my application contains a lot of card?? should i remove the card once it is not in use, or i need to add the card dynamically...??

your suggestion is highly appreciated...

cheers...
0
Comment
Question by:pleasure
[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
  • 3
  • 2
8 Comments
 
LVL 5

Expert Comment

by:fontaine
ID: 7145426
No because the way it works is very simple: the layout manager simply picks up the panel you want to show and displays it, like if it was "alone". That's the whole idea of a CardLayout.
0
 
LVL 3

Expert Comment

by:yasser_helmy
ID: 7145793
The layout manager wont have any problem loading your cards. The number of cards does not affect the performance of the layout manager. You dont have to create the cards dynamically or remove them when they are not needed any more.
But, the number of cards may influence the performance in another way. The more cards you have the more memory your program uses. This reduces performance. But this is true for all variables you use in the program. For example, if you use a very large array of data the performance will be influenced.
0
 

Author Comment

by:pleasure
ID: 7148153
thanks for the response... i wish to open this question for several days in order to wait for opinion from others experts...

cheers...
0
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.

 

Author Comment

by:pleasure
ID: 7153291
hi experts..
i hit problem here.. when my application load too many cards.. sometimes my system cause "Out Of Memory" error, FYI my appliction contain around 70++ cards.. it takes quite long to load the application, everytime the application started, all the cards will be loaded..

how should i fix this?? is there any other workaround i can do?? please guide...

thanks
0
 
LVL 5

Expert Comment

by:fontaine
ID: 7153645
The problem is not with the CardLayout itself. What happens is that you instantiate 70++ classes, what takes time and visibly causes the out of memory error. Despite the CardLayout displays one by one, it holds references to each card what ensures that the cards not displayed are not garbage collected. The only solution I can see is to dynamically add/remove, as far as your cards are visibly too large and too numerous to be kept in memory at once.
0
 

Author Comment

by:pleasure
ID: 7153949
hi fontaine,
can you please show me the way to remove component from card layout?

is it a good idea dynamically add and remove the component from the layout? because from my observation i think the delay of the perfomance is because i instantiate too many classes and not because too many component in the card layout.
0
 
LVL 3

Accepted Solution

by:
yasser_helmy earned 200 total points
ID: 7154243
Hi Pleasure,
The "Out of memory" error is due to the the large number of components you have. The number of instantiated classes does not affect the performance in any way. You have to create the cards when they are needed and make them available for garbage collection whenever you think they wont be needed any more.
You can create only a few cards when the application loads. When you think they are not needed, remove them from the panel, make any references to the these cards null. Create other cards when needed.
0
 
LVL 5

Expert Comment

by:fontaine
ID: 7154635
To add, you use the following CardLayout method:

addLayoutComponent(java.awt.Component, java.lang.Object)

To remove, you use the following:

removeLayoutComponent(Component comp)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

636 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