|
发表于 2021-12-26 12:35:25
|
显示全部楼层
- public Test() {
- JLayeredPane pane = new JLayeredPane();
- JLabel label;
- JPanel panel1 = new JPanel();
- JTextField field1 = new JTextField();
- ImageIcon image;
- // 读取图片注意文件路径和文件后缀
- image = new ImageIcon("0.jpeg");
- label = new JLabel(image);//把图片添加到标签里
- panel1.setBounds(0, 0, image.getIconWidth(), image.getIconHeight()); //把标签设置为和图片等高等宽
- panel1 = (JPanel)this.getContentPane(); //把我的面板设置为内容面板
- panel1.add(label);
- pane.add(panel1,JLayeredPane.DEFAULT_LAYER);
- this.setTitle("派大星");
- this.setBounds(100,100,image.getIconWidth(), image.getIconHeight());
- this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- this.setLayeredPane(pane);
- this.setVisible(true);
- }
- public static void main(String[] args) {
- new Test();
- }
复制代码 |
|