GUI的优化操作/添加背景图片等

一、背景图片的添加
这是JAVA中添加背景图片的方式,基本思路先建立一个Label标签,然后建立一个层次的布局,将label标签添加到最下面去。
 1 ImageIcon image=new ImageIcon("F:\\exploitation\\codes\\java_codes_project\\new_project\\src\\signer\\time5.jpg");
 2         JLabel logo_label = new JLabel(image);
 3 
 4         logo_label.setBounds(0, 0, image.getIconWidth(), image.getIconHeight());
 5 
 6         // 设置底层把图片放在最下面的一层
 7         getLayeredPane().add(logo_label, Integer.valueOf(Integer.MIN_VALUE));
 8 
 9         //设置内容面板  getContentPane前面添加  这个JFrame的对象 由于这个图片是继承了JFrame  所以不需要对象 或者使用this
10         JPanel jp = (JPanel) this.getContentPane();
11 
12         //设置内容面板未透明  true代表透明  透明之后的gui界面是看不到背景图像的
13         jp.setOpaque(false);

猜你喜欢

转载自www.cnblogs.com/future-dream/p/10011624.html