Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Pb with JTabbedPane

Posted on 2002-04-30
Medium Priority
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.
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.


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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 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