導航:首頁 > 編程語言 > java登錄界面背景圖片

java登錄界面背景圖片

發布時間:2023-12-30 09:47:34

java怎麼添加背景圖片

這是我以前的一個小代碼你可以看看
public class demo_9 extends JFrame {
jsplitPane jsp = null;
JList jlist;
JLabel jlabel;

public static void main(String[] args) {
demo_9 a = new demo_9();

}
public demo_9(){
String []words ={"boy","girl"};
JList jlist = new JList(words);
jlabel = new JLabel(new ImageIcon("Image//真三.gif")); //這里就是引入圖片了
//拆分窗格
jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jlist,jlabel);
jsp.setDividerLocation(70);
//設置可以伸縮
jsp.setOneTouchExpandable(true);
this.add(jsp);
this.setTitle("test");
this.setSize(400,300);
this.setLocation(400,200);
this.setVisible(true);
}

}
步驟:首先先在project里新建個文件夾(Folder),然後把你要插入的圖片復制黏貼到這個文件夾裡面。
例如我那個引入的圖片代碼:jlabel = new JLabel(new ImageIcon("Image//真三.gif"));
我new一個folder叫Image,圖片名稱叫"真三.gif"

② java登陸界面如何插入背景圖片

直接上代碼了,這是我以前寫的
packageam_2;
importjava.awt.*;
importjavax.swing.*;
publicclassJLayeredPane_1extendsJFrame{
publicJLayeredPane_1(){
this.setSize(300,400);
JLayeredPanelayeredPane=this.getLayeredPane();
layeredPane.add(newBackgroundPanel(),newInteger(0));//thesameto
//layeredPane.add(panelBg);
layeredPane.add(newPanelContent(),newInteger(1));
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
{
publicBackgroundPanel(){
this.add(newJLabel(getIcon()));
this.setBounds(0,0,300,400);
}
publicImageIcongetIcon(){
finalImageimageBg=Toolkit.getDefaultToolkit().getImage(
this.getClass().getResource("/img/0.jpg"));
ImageIconimageIcon=newImageIcon(imageBg);
returnimageIcon;
}
@
publicvoidpaint(Graphicsg){
ImageimageBg=Toolkit.getDefaultToolkit().getImage(
this.getClass().getResource("/img/0.jpg"));
g.drawImage(imageBg,0,0,300,400,null);
}
}
{
publicPanelContent(){
JButtonbutton=newJButton("測試按鈕1");
JButtonbutton2=newJButton("測試按鈕2");
JButtonbutton3=newJButton("測試按鈕3");
this.setBounds(100,100,100,100);
this.setOpaque(false);//設置為透明
this.add(button);
this.add(button2);
this.add(button3);
}
}
/**
*@paramargs
*@throwsException
*/
publicstaticvoidmain(String[]args){
//TODOAuto-generatedmethodstub
JLayeredPane_1frame=newJLayeredPane_1();
}
}

閱讀全文

與java登錄界面背景圖片相關的資料

熱點內容
c獲取當前文件名 瀏覽:212
3dmax9怎麼打開文件 瀏覽:965
iphone刪除的app還在 瀏覽:100
ug編程怎麼復制圖層 瀏覽:980
keil中自己編寫c語言頭文件 瀏覽:261
xp換成win7後文件只讀 瀏覽:279
檢測數據是什麼 瀏覽:151
如何編程製造游戲 瀏覽:791
電腦文件快捷鍵 瀏覽:793
看在一起多久的app 瀏覽:953
公文中什麼時候有文件 瀏覽:668
小孩編程有什麼語言 瀏覽:373
壞女孩qq相冊密碼 瀏覽:886
如何用計算器上下編程 瀏覽:804
如何把exe文件綁到一張圖片上 瀏覽:168
discuz網站搬家不想丟文件 瀏覽:439
編程里的隨機和坐標指的是什麼 瀏覽:337
澄海小學生哪裡可以學編程 瀏覽:631
電腦用什麼app錄屏 瀏覽:634
絢星視頻文件在哪裡 瀏覽:567

友情鏈接