如何实现3层依次Overlay的JPanel(大小相同),而且每层JPanel均为可见,即上2层的JPanel为“透明” 什么叫“每层JPanel均为可见,即上2层的JPanel为“透明”” 不过你可以参考JLayerredPane 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以设一下上面两层的Visiable为假试试 形象地说比如有3张同样大小的纸每张上都画有文字,方块和圆圈等图形将3张纸叠在成一张从上往下看要求可以看到3张纸上所有的文字和图形也就是说,最上面那张和中间那张纸,实际上要变成一张透明的塑料薄膜大家明白了么有法子么JPanel层叠是可以的但是如何让JPanel的背景变成透明的塑料薄膜阿 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 Frame1 extends JFrame { JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); JLayeredPane jLayeredPane1 = new JLayeredPane(); OverlayLayout2 overlayLayout21 = new OverlayLayout2(); JPanel jPanel1 = new JPanel(); JButton jButton1 = new JButton(); JPanel jPanel2 = new JPanel(); JButton jButton2 = new JButton(); BorderLayout borderLayout2 = new BorderLayout(); BorderLayout borderLayout3 = new BorderLayout(); JPanel jPanel3 = new JPanel(); JButton jButton3 = new JButton(); BorderLayout borderLayout4 = new BorderLayout(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); this.setSize(new Dimension(530, 446)); this.setTitle("Frame Title"); jLayeredPane1.setBackground(SystemColor.info); jLayeredPane1.setLayout(overlayLayout21); jPanel1.setBackground(Color.pink); jPanel1.setLayout(borderLayout2); jPanel1.setOpaque(false); jButton1.setText("jButton1"); jPanel2.setBackground(Color.green); jPanel2.setLayout(borderLayout3); jPanel2.setOpaque(false); jButton2.setText("jButton2"); jPanel3.setBackground(SystemColor.desktop); jPanel3.setLayout(borderLayout4); jPanel3.setOpaque(false); jButton3.setText("jButton3"); contentPane.add(jLayeredPane1, BorderLayout.CENTER); jLayeredPane1.add(jPanel1, null); jPanel1.add(jButton1, BorderLayout.NORTH); jLayeredPane1.add(jPanel2, null); jPanel2.add(jButton2, BorderLayout.EAST); jLayeredPane1.add(jPanel3, null); jPanel3.add(jButton3, BorderLayout.SOUTH); } //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); } }} package test1;import javax.swing.UIManager;import java.awt.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Application1 { boolean packFrame = false; //Construct the application public Application1() { Frame1 frame = new Frame1(); //Validate frames that have preset sizes //Pack frames that have useful preferred size info, e.g. from their layout if (packFrame) { frame.pack(); } else { frame.validate(); } //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); } //Main method public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { e.printStackTrace(); } new Application1(); }} 在installanyanywhere中能运行并安装MsSql2000吗? 初学JAVA,一个简单的编程题。 javamail收新浪邮件问题 java抽象类 接口的区别 如何让Java程序只能启动一次呢? 急~~~~~~~~~RMI问题 jtable如何隐藏行和列并且不影响setValueAt 明天晚上就回家过年了,年前先散分发红包,大家过年好 救命啊, linux 下java访问mysql…… Java中,如果要break mylabel;mylabel是否被限制在一定的位置? 哪里可以取得ant 究竟是什么问题?
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 Frame1 extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JLayeredPane jLayeredPane1 = new JLayeredPane();
OverlayLayout2 overlayLayout21 = new OverlayLayout2();
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JPanel jPanel2 = new JPanel();
JButton jButton2 = new JButton();
BorderLayout borderLayout2 = new BorderLayout();
BorderLayout borderLayout3 = new BorderLayout();
JPanel jPanel3 = new JPanel();
JButton jButton3 = new JButton();
BorderLayout borderLayout4 = new BorderLayout(); //Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(530, 446));
this.setTitle("Frame Title");
jLayeredPane1.setBackground(SystemColor.info);
jLayeredPane1.setLayout(overlayLayout21);
jPanel1.setBackground(Color.pink);
jPanel1.setLayout(borderLayout2);
jPanel1.setOpaque(false);
jButton1.setText("jButton1");
jPanel2.setBackground(Color.green);
jPanel2.setLayout(borderLayout3);
jPanel2.setOpaque(false);
jButton2.setText("jButton2");
jPanel3.setBackground(SystemColor.desktop);
jPanel3.setLayout(borderLayout4);
jPanel3.setOpaque(false);
jButton3.setText("jButton3");
contentPane.add(jLayeredPane1, BorderLayout.CENTER);
jLayeredPane1.add(jPanel1, null);
jPanel1.add(jButton1, BorderLayout.NORTH);
jLayeredPane1.add(jPanel2, null);
jPanel2.add(jButton2, BorderLayout.EAST);
jLayeredPane1.add(jPanel3, null);
jPanel3.add(jButton3, BorderLayout.SOUTH);
}
//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);
}
}
}
import java.awt.*;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class Application1 {
boolean packFrame = false; //Construct the application
public Application1() {
Frame1 frame = new Frame1();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new Application1();
}
}