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);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM