Solved

Pb with JTabbedPane

Posted on 2002-04-30
7
568 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

743 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

14 Experts available now in Live!

Get 1:1 Help Now