*
The moose likes Swing / AWT / SWT and the fly likes canvas on JTabbedPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "canvas on JTabbedPane" Watch "canvas on JTabbedPane" New topic
Author

canvas on JTabbedPane

Sarone Thach
Ranch Hand

Joined: Jun 25, 2003
Posts: 89
Hi there,
I have this problem I have been battling with for over a week now.
I have a JTabbedPane and added a JPanel to index 0, behind (index 1) it i added a JPanel with a custom Canvas and other components, ie myCanvas extends Canvas.
The problem is, when run my program, the canvas is painted on top of the JTabbedPane, when its supposed to be hidden with all the "other components". If I select index 1 of the JTabbedPane everything in this page is displayed. if i select index 0, it shoulds everything in index 0, without the canvas. So only on initial start up i have this problem.
So i figured my canvas class is wrong. But don't know actually what is wrong.
I would submitt the code, but it's very long.
Does anyone have a clue why the canvas insists being on top when its not supposed to be on startup?
thanks,
Sarone
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Canvas is an AWT component... JTabbedPane and JPanel are Swing Components...

You shouldn't mix the two.

Replace your subclass of Canvas with a subclass of JPanel (and put the code from the Canvas's paint() method into the JPanel's paintComponent() method) and it should work, though.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: canvas on JTabbedPane
 
Similar Threads
Artifacts appearing outside of JScrollPane
Canvas in JScrollPane
Need help with this code
JScrollPane and Canvas problem
Tab order in swing component