JAVA,解释一下这些话每句话的意思.((JPanel) this.getContentPane()).setOpaque(false);ImageIcon img = new ImageIcon("image/对对碰1.jpg");JLabel background = new JLabel(img);this.getLayeredPane().add(background, new Integer(Integer.M

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/12 05:49:47

JAVA,解释一下这些话每句话的意思.((JPanel) this.getContentPane()).setOpaque(false);ImageIcon img = new ImageIcon("image/对对碰1.jpg");JLabel background = new JLabel(img);this.getLayeredPane().add(background, new Integer(Integer.M
JAVA,解释一下这些话每句话的意思.
((JPanel) this.getContentPane()).setOpaque(false);
ImageIcon img = new ImageIcon("image/对对碰1.jpg");
JLabel background = new JLabel(img);
this.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
background.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());

JAVA,解释一下这些话每句话的意思.((JPanel) this.getContentPane()).setOpaque(false);ImageIcon img = new ImageIcon("image/对对碰1.jpg");JLabel background = new JLabel(img);this.getLayeredPane().add(background, new Integer(Integer.M
该类应该继承了JFrame 类
this.getContentPane(); 得到的是一个容器 (Container)对象
(JFrame)this.getContentPane() ; 将该容器 (Container) 强转为面板对象(JFrame)
((JPanel) this.getContentPane()).setOpaque(false); 将该面板设置为透明;
ImageIcon img = new ImageIcon("image/对对碰1.jpg"); 创建一个图标(ImageIcon)对象
JLabel background = new JLabel(img); 创建一个标签,并将上面创建的图标对象给该标签,意思是该标签的背景就是 image文件夹下面 “对对碰1.jpg”这张图片了
this.getLayeredPane() 得到一个JLayeredPane 对象,这个类为容器添加了深度,允许组件在需要时互相重叠.
this.getLayeredPane().add(background,new Integer(Integer.MIN_VALUE)); 这句话的意思是,为前面创建的标签 设置层的深度,这里将其设置为了最底层,因为Integer.MIN_VALUE是int类型的最小值了
background.setBounds(0,0,img.getIconWidth(),img.getIconHeight()); 这里是调整label标签在容器的位置,并调整该标签的大小
这里有四个参数,前面两个是确定在容器中的位置的,后面两个是调整标签的大小的,这里它定义的是在容器的 左上角位置,标签的长 和宽 跟“对对碰1.jpg”这张图片的长和宽相等.

(这getcontentpane()(录入)。)。setopaque(假);按钮图片=新按钮(“图像/对对碰1了。”);jlabel背景=新jlabel(公司);这getlayeredpane()。。加(背景,新的整数(整数min_value。));背景。setbounds(0,-0,-geticonheight()geticonwidth(),。。);