Link to home
Start Free TrialLog in
Avatar of stdt
stdt

asked on

Pb with JTabbedPane

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.
Avatar of Venci75
Venci75

try to call the repaint() method explicitly
Avatar of stdt

ASKER

I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
Avatar of stdt

ASKER

I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
Avatar of stdt

ASKER

I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
Avatar of stdt

ASKER

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 ?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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