当前位置:首页 » 背景图片 » java登入界面有背景图片
扩展阅读
淘宝手机端图片规格 2024-09-29 01:16:07

java登入界面有背景图片

发布时间: 2024-01-30 19:53:33

Ⅰ 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;
}
@Override
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如何为登陆窗口添加背景图片

登录的窗口主界面JFrame,调用getContentPane(),获取到面板。

JPanel J=(JPanel)this.getContentPane();

创建一个带图标的标签。

JLabel jb=new JLabel(new ImageIcon("xx.jpg"));

添加该标签,并设置为窗口的大小。

J.add(jb);

jb.setBounds(0, 0, this.getWidth(), this.getHeight());

如果在JFrame中还有其他的覆盖于其上的JPanel,需要将其设为透明,

setOpaque(true);

注:代码为JFrame的构造函数中完成,其This指代窗口当前实例。

Ⅲ 用eclipse做一个登陆界面 怎样添加背景图片 最好就详细说明 谢谢

这是在JSP中实现的。JSP中的页面代码和HTML的差不多,你要是会写HTML,那你就把你的HTML代码直接复制到JSP页面中来

Ⅳ 想在java学生管理系统的登陆界面添加背景图片,但不知在什么地方添加代码

1、在Body中添加
<html>
<head><title></title></head>
<body background="背景图片地址">
</body>
</html>

2、在登录框的div添加
<div id="login" style="background-image: 背景图片地址">

3、在css添加
在body添加:
BODY {
background-image: 图片路径地址
}

根据ID添加
#login{
background-image: 图片路径地址
}

这些都可以的,还有js也可以添加的。

Ⅳ java怎样在登陆界面添加背景图片最好有代码及详解,先谢谢了各位大神!!!

有两种方式,一个是用CSS层叠样式表设定,第二个就是在<div>里面写,代码我这也有一些,我给你,在CSS文件中写body {
background:#fff;写上要用的背景图片url,一般设一个包中,写入路径
font-size:12px;
color:#000;
font-family:"宋体";
height:100%;
}