Article View: borland.public.jbuilder.java.swing
Article #1199JLayeredPanes are not showing up!
From: Ishan
Date: Sat, 07 Feb 2004 20:42
Date: Sat, 07 Feb 2004 20:42
63 lines
2703 bytes
2703 bytes
I can't get his code to work.
The layers will not display. Please help. It's on XP, using JBuilder 9.
package testinglayers;
import javax.swing.*;
import java.awt.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class layerDemo {
public layerDemo() {
JFrame jf = new JFrame("Layered Demo");
JLabel lb = new JLabel("Testing");
JLabel lb2 = new JLabel("Testing 2");
JLayeredPane lp = new JLayeredPane();
JLayeredPane lp2 = jf.getLayeredPane();
lp2.setSize(new Dimension(200,200));
jf.setBackground(Color.WHITE);
lp2.enable();
lp2.doLayout();
lp2.setSize(new Dimension(400,400));
lp2.add(lb, JLayeredPane.DEFAULT_LAYER);
lp2.add(lb2, JLayeredPane.PALETTE_LAYER);
lp2.setBackground(Color.PINK);
lp2.show();
// lp2.show(true);
lp2.validate();
lp2.grabFocus();
jf.setSize(new Dimension(500,500));
// lp2.setEnabled(true);
lp2.setForeground(Color.BLUE);
System.out.println("Size of Layer: " +lp2.getSize());
System.out.println("Is Enable: " + lp2.isEnabled());
System.out.println("Is Showing: " + lp2.isShowing());
lp2.setVisible(true);
System.out.println("Is Visable: " + lp2.isVisible());
System.out.println("Is Displayable: " + lp2.isDisplayable());
System.out.println("Is DoubleBuffered: " + lp2.isDoubleBuffered());
// jf.getContentPane().setBackground(Color.WHITE);
jf.setLayeredPane(lp2);
jf.show();
// System.out.println("This is the total number of components: " + lp2.countComponents());
}
public static void main(String[] args) {
layerDemo layerDemo1 = new layerDemo();
}
}
This is driving me crazy!!!!!
Technical Details
Message-ID:
<40254db4$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,bdb19836988117a7,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-02-07 12:58:06 PST From: "Ishan" <ishan@canaantechnologies.com> Sender: "Ishan" <ishan@canaantechnologies.com> Reply-To: "Ishan" <ishan@canaantechnologies.com> Subject: JLayeredPanes are not showing up! Newsgroups: borland.public.jbuilder.java.swing X-User-Info: 66.189.125.31 X-Forwarded-For: 66.189.125.31 NNTP-Posting-Host: 207.105.83.66 Message-ID: <40254db4$1@newsgroups.borland.com> Date: 7 Feb 2004 12:42:28 -0800 X-Trace: newsgroups.borland.com 1076186548 207.105.83.66 (7 Feb 2004 12:42:28 -0800) Lines: 64 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!newsgroups.borland.com!not-for-mail