Solved

Pb with JTabbedPane

Posted on 2002-04-30
7
569 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
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.

 

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

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

864 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

20 Experts available now in Live!

Get 1:1 Help Now