Solved

Pb with JTabbedPane

Posted on 2002-04-30
7
573 Views
Last Modified: 2012-06-22
In my application, i've build a JTabbedPane, with 2 tabs.
The second tab contains a JPanel which contains a subclass of Canvas at the center.

When i start the application, the first tab is selected, but it paint the canvas of the second tab. Then, when i select de 2nd tab then the 1st by clicking, the content of the 1st tab become correct again.
It's at the init of the JTabbedPane that the problem occur.
I've tried to call :
tabbedPane.setSelectedIndex(1);
tabbedPane.setSelectedIndex(0);
to force to repaint 2nd tab then 1st tab, but to no effect.

Does anybody know this problem or similar ?
Thanks a lot.
0
Comment
Question by:stdt
  • 4
  • 2
7 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 6980039
try to call the repaint() method explicitly
0
 

Author Comment

by:stdt
ID: 6980189
I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
0
 

Author Comment

by:stdt
ID: 6980281
I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:stdt
ID: 6980302
I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
0
 

Author Comment

by:stdt
ID: 6980470
OTHER QUESTION :
I've made a test by replacing the Canvas by a JPanel in the 2nd tab, and the problem has disapeared. In fact the Canvas witch is AWT is painted wherever it is. And the management of a JTabbedPane with a Canvas is bad.
In fact, i use a Canvas component because i just need to paint in the Graphics.

Is there a Swing component like Canvas in AWT ?
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6982422
You should not be using a heavyweight component (Canvas) inside your JTabbedPane (lightweight component).
Instead of using a Canvas just use a JPanel, or subclass JComponent.
0
 
LVL 92

Expert Comment

by:objects
ID: 7012665
Just use a subclass of JComponent, or a JPanel.

Thanks for the points :-)

http://www.objects.com.au
Brainbench MVP for Java 1
http://www.brainbench.com
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SHA2 certs for IIS AND Java? 2 122
CSV file parsing thru Java 13 40
going to wrong jsp page 2 50
Java syntax, or is it Selenium 6 43
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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.

726 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