导航:首页 > 编程语言 > 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登录界面背景图片相关的资料

热点内容
js脚本不起作用 浏览:317
iphone3g怎么升级 浏览:341
deadtrigger2安卓 浏览:419
手机系统空间的文件怎么看 浏览:113
vbaword表格中的表格 浏览:585
建账的初始数据是从哪个表上填写 浏览:986
广州做网站费用多少 浏览:691
隐藏app图标ios9 浏览:446
苹果62g网络 浏览:730
java读取xml格式数据 浏览:170
java商品推送 浏览:708
网上的视频文件打不开 浏览:237
用phpcms建网站流程 浏览:973
word2010表格数字递增 浏览:273
数据库表的大小 浏览:452
天津编程考试哪里好 浏览:792
苹果手机更新系统后系统文件过大 浏览:810
js的事件有什么区别 浏览:763
图片中植入程序 浏览:832
数控机床编程哪里能学 浏览:110

友情链接