導航:首頁 > 圖片大全 > 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中圖標如何換圖片相關的資料

熱點內容
女生的動漫的圖片 瀏覽:283
闞清子發型圖片大全 瀏覽:640
word設置背景圖片過大 瀏覽:960
素描鹿晗圖片簡單 瀏覽:762
手機如何把相冊里圖片壓縮 瀏覽:389
word2007圖片文字夾住了 瀏覽:741
男生改發型圖片 瀏覽:119
鎖骨發型裁剪圖片 瀏覽:12
美女好心情圖片 瀏覽:679
騰訊文檔上傳圖片了怎麼保存 瀏覽:287
古裝短發圖片大全男生 瀏覽:766
用粘土做東西可愛簡單圖片 瀏覽:293
媽媽真可愛的圖片 瀏覽:549
java中圖標如何換圖片 瀏覽:121
男生拍圖片發女生 瀏覽:585
tom貓高清圖片貓和老鼠 瀏覽:525
美女惡搞動態圖片大全 瀏覽:653
男生穿公主鞋的圖片 瀏覽:224
知足常樂圖片可愛圖片 瀏覽:571
美容院貨架圖片大全 瀏覽:463