Solved

JComboBox after JPanel.repaint

Posted on 2003-11-23
4
578 Views
Last Modified: 2008-03-03
Hi,
I have a JPanel(parent) on which I am GridLayout. In my JPanel, I have two panels(child1,child2) added. Both these panels have a ComboBox. The actionListener causes the bigger panel to be repainted. Now, when if my child1.ComboBox has some item selected, how do I show it in the JComboBox next to the arrow. After a repaint, I am getting  a default value at the combo boxes.



0
Comment
Question by:miteshn
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
Tols earned 200 total points
ID: 9808887
Hi, You may use:

child1.setSelectedItem(obj);
0
 

Author Comment

by:miteshn
ID: 9810404
When I do that, it initializes the action listener, and goes into an infinite loop. I want my combo boxes to save their status before a repaint, and show the item last selected.

thanks
0
 

Author Comment

by:miteshn
ID: 9814548
i actually figured it out...first, remove the actionListeners, and then setSelectedItem. then add actionListeners again...
0
 
LVL 2

Expert Comment

by:Tols
ID: 9816180
Sorry for less of answer. In my country it was deep night. :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 39
groupSum5 challenge 5 71
egit plugin on eclipse 8 40
servlet web applications   metadata-complete="true" or false 3 3
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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 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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now