Re: using JLayeredPane
- From: "Monique Y. Mudama" <spam@xxxxxxxxxxxxxxxx>
- Date: Mon, 27 Feb 2006 12:48:27 -0700
On 2006-02-27, Vova Reznik penned:
Monique Y. Mudama wrote:
Is it possible to successfully add it to another JComponent, or mustMust not.
you set it as the contentPane of a JFrame?
http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html
"...Every Swing container that has a root pane ? such as JFrame,
JApplet, JDialog, or JInternalFrame ? automatically has a layered
pane. ..."
Thank you, but that wasn't really what I was trying to get at. None
of the containers described in that quote are JComponents.
I don't want the entire JApplet to use a layered pane. I want a
subsection, added to a JPanel, to be layered.
The tutorial you linked, which I have read (but possibly not in enough
detail), has example code that uses JFrame's setContentPane() method to
use a custom built JLayeredPane. I want to know if I can do something
like:
JPanel panel = new JPanel();
JLayeredPane layers = new JLayeredPane();
// add stuff to JLayeredPane
panel.add(layers);
So far, it hasn't worked: the area that should contain the layers is
just grey/blank.
Here's some example code; the actual app for which I'd like this
functionality is pretty complicated. But I think if I could get this
sample to work, I could also get the app to work:
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
public class LayeredPaneTest
{
public static void main (String[] args)
{
go();
protected static void go()
{
JFrame frame = new JFrame();
JLayeredPane pane = new JLayeredPane();
pane.add(new JLabel("foo"), new Integer(0));
pane.add(new JLabel("bar"), new Integer(1));
frame.getContentPane().add(pane);
frame.pack();
frame.setVisible(true);
}
}
}
--
monique
.
- Follow-Ups:
- Re: using JLayeredPane
- From: Vova Reznik
- Re: using JLayeredPane
- From: Monique Y. Mudama
- Re: using JLayeredPane
- References:
- using JLayeredPane
- From: Monique Y. Mudama
- Re: using JLayeredPane
- From: Vova Reznik
- using JLayeredPane
- Prev by Date: Re: Draw pointable / pickable lines, etc, how to?
- Next by Date: Re: using JLayeredPane
- Previous by thread: Re: using JLayeredPane
- Next by thread: Re: using JLayeredPane
- Index(es):
Relevant Pages
|