導航:首頁 > 圖片大全 > java中圖標如何換圖片

java中圖標如何換圖片

發布時間:2025-09-04 22:55:29

Ⅰ java圖形界面圖片,覆蓋文字怎麼

重畫面板,將圖片當成背景,在圖片之上畫控制項
參考下我的這串代碼
public void serverframe() {
int x, y;
x = 600;
y = 480;
Toolkit theKit = getToolkit();
Dimension winSize = theKit.getScreenSize(); //獲取當前顯示器解析度
setBounds((winSize.width - x) / 2, (winSize.height - y) / 2, x, y); //主窗體在屏幕居
this.setTitle("簡易區域網聊天工具");
Toolkit kit =Toolkit.getDefaultToolkit();//更改左上角小圖標
Image image = kit.createImage(getClass().getResource("images/10.png"));
this.setIconImage(image);
setBak(); //調用背景方法
Container c = getContentPane(); //獲取JFrame面板
JPanel jp = new JPanel(); //創建個JPanel
jp.setOpaque(false); //把JPanel設置為透明 這樣就不會遮住後面的背景 這樣就能在JPanel隨意加組件
c.add(jp);
setLayout(null);

label.setBounds(new Rectangle(20, 0, 460, 20));
txarea.setBounds(new Rectangle(20, 20, 460, 280));
label1.setBounds(new Rectangle(20, 320, 460, 20));
txfield.setBounds(new Rectangle(20, 340, 460, 90));
btnend.setBounds(new Rectangle(490, 20, 100, 30));
btnend1.setBounds(new Rectangle(490, 55, 100, 30));
btnend2.setBounds(new Rectangle(490, 90, 100, 30));
btnend3.setBounds(new Rectangle(490, 125, 100, 30));
btnend4.setBounds(new Rectangle(490, 160, 100, 30));
btnend5.setBounds(new Rectangle(490, 195, 100, 30));
btnend6.setBounds(new Rectangle(490, 230, 100, 30));
btnend7.setBounds(new Rectangle(490, 265, 100, 30));
btnend8.setBounds(new Rectangle(490, 380, 100, 50));

add(label);
add(txarea);
add(label1);
add(txfield);
add(btnend);
add(btnend1);
add(btnend2);
add(btnend3);
add(btnend4);
add(btnend5);
add(btnend6);
add(btnend7);
add(btnend8);
this.addWindowListener(new WindowAdapter() {

@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
txfield.addActionListener(new textlistener());
this.setResizable(false);
setVisible(true);
connect();
}

public void setBak() { //設置窗口背景
((JPanel) this.getContentPane()).setOpaque(false);
ImageIcon img = new ImageIcon(getClass().getResource("images/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中圖標如何換圖片相關的資料

熱點內容
心痛女孩子的動態圖片 瀏覽:186
女孩白色內內圖片 瀏覽:203
入冬早上好文字圖片 瀏覽:616
帥氣男生換裝圖片 瀏覽:215
短發面條卷發型圖片 瀏覽:1000
可愛小孩子圖片賣萌 瀏覽:638
花的圖畫手繪簡單圖片 瀏覽:768
動漫公主服裝圖片大全圖片大全 瀏覽:173
動漫繪畫作品圖片 瀏覽:127
小女孩幾幾的現狀圖片 瀏覽:291
櫻花圖片動漫圖 瀏覽:742
成熟潮男搭配衣服圖片 瀏覽:167
動漫人物圖片大全黑白 瀏覽:1088
最多動漫圖片 瀏覽:844
小鳥衣服圖片大全可愛 瀏覽:510
手擋太陽的圖片女生 瀏覽:555
男女生圖片背影圖片 瀏覽:1089
想太多心會累文字圖片 瀏覽:433
簡單動漫圖片教程視頻 瀏覽:621
女孩發育圖片視頻 瀏覽:621