my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes adding swing component on canvas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "adding swing component on canvas" Watch "adding swing component on canvas" New topic

adding swing component on canvas

cinderalla rahul

Joined: Jan 11, 2002
Posts: 9
is it possible to add swing component JPanel,JLabel to canvas.
If so how, is it possible to do the following.

I have a JPanel which has background image.Two texfields are placed over the JPanel.
This I have done using Quicktime.
Backgroundimage is placed in JPanel by this method:
Image is placed in QTCanvas & then its placed in JPanel.
I have to place two JTextField in that JPanel.But i could not place it.How could i add components to JPanel which has Backgroundimage placed using QtCanvas.
I do get an exception while i am trying to place component over a panel which has QTCanvas.
Exception during add: java.lang.ClassCastException: java.awt.LightweightPeer

So pl.. suggest me a solution,immediately as soon as possible.
with regards,
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Cinderalla,
You can't overlap components. The only thing you can do is to draw the image onto the JPanel (i.e., overridding paintComponent method) and then place the JTextFields into the JPanel.
I agree. Here's the link:
subject: adding swing component on canvas
It's not a secret anymore!