導航:首頁 > 編程語言 > 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登錄界面背景圖片相關的資料

熱點內容
怎麼查一個網站的外鏈 瀏覽:675
linux下db2安裝時版本選擇 瀏覽:738
匯編編程用哪個軟體 瀏覽:486
仙樂下的歌在文件管理哪裡 瀏覽:477
115網盤解析工具2014 瀏覽:371
內圓弧銑刀怎麼編程 瀏覽:410
記事本文件轉word格式對齊 瀏覽:300
excel刪除恢復文件 瀏覽:290
三星s4怎麼切換3g網路 瀏覽:994
什麼是網站維護 瀏覽:314
文件夾錄像在哪裡 瀏覽:621
可以發語音的是什麼app 瀏覽:804
恢復手機桌面文件管理 瀏覽:627
用什麼軟體可以打開psd文件 瀏覽:459
公安有哪些警務app 瀏覽:150
生意轉租用什麼app 瀏覽:683
廣義的網路信息保密性是指 瀏覽:657
qq背景唯美簡約圖片 瀏覽:292
sky網路電話怎麼收費 瀏覽:599
編程公司哪個比較好 瀏覽:182

友情鏈接