layeredpaneexp.java

来自「里面是学习JAVA时的一些小程序代码,教学时可以用到.包括图像界面的编辑等方面的」· Java 代码 · 共 53 行

JAVA
53
字号
/**
 * @(#)LayeredPaneExp.java
 *
 *
 * @author 
 * @version 1.00 2007/11/12
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class Win extends JFrame  {
  JLayeredPane  p;
  JLabel  lab;
  JButton btn;
  
  Win(String s) {
   super(s);
   p=new JLayeredPane();
   lab=new JLabel(new ImageIcon("E:/backgroud.jpg"));
   lab.setPreferredSize(p.getSize());
   p.add(lab,new Integer(0));
   btn=new JButton("Click here!");
   btn.setBounds(20,20,50,30);
  // p.add(btn,JLayeredPane.DRAG_LAYER);
   
   add(p);
   //add(lab);
   setSize(500,500);
   setVisible(true);
   validate();
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
   
   
  }
}
public class LayeredPaneExp {
        
    /**
     * Creates a new instance of <code>LayeredPaneExp</code>.
     */
    public LayeredPaneExp() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        new Win("Example Window");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?