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.setSelectedInde x(1);
tabbedPane.setSelectedInde x(0);
to force to repaint 2nd tab then 1st tab, but to no effect.
Does anybody know this problem or similar ?
Thanks a lot.
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.setSelectedInde
tabbedPane.setSelectedInde
to force to repaint 2nd tab then 1st tab, but to no effect.
Does anybody know this problem or similar ?
Thanks a lot.
try to call the repaint() method explicitly
ASKER
I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
ASKER
I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
ASKER
I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
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 ?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Thanks for the points :-)
http://www.objects.com.au
Brainbench MVP for Java 1
http://www.brainbench.com