Re: JLayeredPane possible in BorderLayout.CENTER ?
- From: "alex_us01" <arisalex@xxxxxxxxx>
- Date: 30 Sep 2005 11:01:08 -0700
as far as i understand, that is because there is no layout manager is
set for the JLayeredPane.
Solution:
either: lpane.setLayoutManager( /* some manager */ );
or: tlabel.setBounds(0,0,100,10);
and here is the code that shows overlapping components:
============================================
import java.awt.*;
import javax.swing.*;
public class LPTry {
public static void main(String[] args) {
JFrame jf = new JFrame();
jf.getContentPane().setLayout(new BorderLayout());
JLabel tlabel = new JLabel("east");
jf.getContentPane().add(tlabel, BorderLayout.EAST);
JLayeredPane lpane = new JLayeredPane();
tlabel = new JLabel("center bottom");
tlabel.setBounds(0,0,100,10);
lpane.setPreferredSize(new Dimension(200,100));
lpane.add(tlabel, JLayeredPane.DEFAULT_LAYER);
tlabel = new JLabel("center top");
tlabel.setBounds(0,0,100,10);
tlabel.setForeground(Color.RED);
tlabel.setOpaque(false);
lpane.add(tlabel, JLayeredPane.PALETTE_LAYER);
jf.getContentPane().add(lpane, BorderLayout.CENTER);
jf.pack();
jf.setVisible(true);
}
}
.
- Follow-Ups:
- Re: JLayeredPane possible in BorderLayout.CENTER ?
- From: Vova Reznik
- Re: JLayeredPane possible in BorderLayout.CENTER ?
- References:
- JLayeredPane possible in BorderLayout.CENTER ?
- From: alex_us01
- JLayeredPane possible in BorderLayout.CENTER ?
- Prev by Date: Re: ExceptionInInitializerError: NullPointerException
- Next by Date: Re: JLayeredPane possible in BorderLayout.CENTER ?
- Previous by thread: JLayeredPane possible in BorderLayout.CENTER ?
- Next by thread: Re: JLayeredPane possible in BorderLayout.CENTER ?
- Index(es):