Pb with JTabbedPane

Posted on 2002-04-30
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 :
to force to repaint 2nd tab then 1st tab, but to no effect.

Does anybody know this problem or similar ?
Thanks a lot.
Question by:stdt
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Expert Comment

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

Author Comment

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

Author Comment

ID: 6980281
I've tried to call the repaint() method and even the repaintImmediately(...) method, unsuccessfully.
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now


Author Comment

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

Author Comment

ID: 6980470
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 ?
LVL 92

Accepted Solution

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.
LVL 92

Expert Comment

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

Thanks for the points :-)
Brainbench MVP for Java 1

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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…

729 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