JLayeredPane中是否能够插入不同Layer的Container? all way as follows:JLayeredPanel jLP = new JLayeredPanel();JPanel jP = new JPanel();jLP.add(jP); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 但是我这么做了以后再设置JPanel的背景为红色执行的时候JPanel没有显示出来阿 我觉的是应该在JPANEL上再插入象JLABEL,LBUTTON之类。JPANEL显示出来能看到吗? 应该是可以的阿,JPanel、JScrollPanel都是组件阿是不是他们被遮盖掉了? package test1;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame4 extends JFrame{ JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); JLayeredPane jLayeredPane1 = new JLayeredPane(); JPanel jPanel1 = new JPanel(); JPanel jPanel2 = new JPanel(); XYLayout xYLayout1 = new XYLayout(); //Construct the frame public Frame4() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel)this.getContentPane(); contentPane.setBackground(SystemColor.info); contentPane.setDebugGraphicsOptions(0); contentPane.setLayout(borderLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); jLayeredPane1.setBackground(Color.red); jLayeredPane1.setOpaque(true); jLayeredPane1.setLayout(xYLayout1); jPanel1.setBackground(Color.magenta); jPanel1.setPreferredSize(new Dimension(150, 100)); jPanel2.setBackground(Color.green); jPanel2.setPreferredSize(new Dimension(100, 150)); jLayeredPane1.add(jPanel2, new XYConstraints(5, 5, -1, -1)); jLayeredPane1.add(jPanel1, new XYConstraints(5, 160, -1, -1)); contentPane.add(jLayeredPane1, BorderLayout.CENTER); jLayeredPane1.setLayer(jPanel1, 50); jLayeredPane1.setLayer(jPanel2, 30); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } }} java process 关闭窗口 关于hashCode 从数据库读取字符串判断是否为非法字符,用正则替换。。。。急等!! 告急,明天去智乐软件笔试,求笔试题目,谢过 jsp 调试 字符编码的两个问题 Frame窗口的位置 java里的scanf("%d,%s",i,s)是哪个函数? 怎样在JB7里面设置MySQL的JDBC驱动? 请问哪儿有jbuilder的中文版教程下载?100分相送 到我的论坛看看吧,我一定尽力回答大家问题albert.mycool.net 请问有哪位大侠用过jxl.jar这个包,假如一个cell是多行多列的怎么设置?
JPANEL显示出来能看到吗?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class Frame4
extends JFrame
{
JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); JLayeredPane jLayeredPane1 = new JLayeredPane();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
XYLayout xYLayout1 = new XYLayout(); //Construct the frame public Frame4()
{
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
} //Component initialization
private void jbInit()
throws Exception
{
contentPane = (JPanel)this.getContentPane();
contentPane.setBackground(SystemColor.info);
contentPane.setDebugGraphicsOptions(0);
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
jLayeredPane1.setBackground(Color.red);
jLayeredPane1.setOpaque(true);
jLayeredPane1.setLayout(xYLayout1);
jPanel1.setBackground(Color.magenta);
jPanel1.setPreferredSize(new Dimension(150, 100));
jPanel2.setBackground(Color.green);
jPanel2.setPreferredSize(new Dimension(100, 150));
jLayeredPane1.add(jPanel2, new XYConstraints(5, 5, -1, -1));
jLayeredPane1.add(jPanel1, new XYConstraints(5, 160, -1, -1));
contentPane.add(jLayeredPane1, BorderLayout.CENTER);
jLayeredPane1.setLayer(jPanel1, 50);
jLayeredPane1.setLayer(jPanel2, 30); } //Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING)
{
System.exit(0);
}
}
}