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

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