java窗体如何添加背景图片 5

packagejwglxt;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Compone... package jwglxt;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Login1{
JFrame jframe = new JFrame("教务管理系统登陆");
Container con =jframe.getContentPane();
private JTextField username = new JTextField();
private JTextField password = new JTextField();
private JTextField code = new JTextField();
private JButton login = new JButton("登陆");
private JButton reset = new JButton("重置");
public Login1() {
jframe.setBounds(450,300,500,300);
jframe.setLayout(new BorderLayout());
initjframe();
//con.setVisible(false);
jframe.setVisible(true);
jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}
void initjframe() {
//头 即叫务管理系统
JPanel titleJPanel = new JPanel();
titleJPanel.setLayout(new FlowLayout());
JLabel title =new JLabel("教务管理系统");
title.setFont(new Font("楷体",Font.BOLD,20));
titleJPanel.add(title);
jframe.add(titleJPanel,"North");

//中部即文本区域即用户输入数据
JPanel systemJPanel = new JPanel();
systemJPanel.setLayout(null);
JLabel a = new JLabel("用户名:");
a.setFont(new Font("楷体",Font.BOLD,15));
a.setBounds(100,50,60,20);
JLabel b = new JLabel("密 码:");
b.setFont(new Font("楷体",Font.BOLD,15));
b.setBounds(100,80,60,20);
JLabel c =new JLabel("验证码:");
c.setFont(new Font("楷体",Font.BOLD,15));
c.setBounds(100,110,60,20);
username.setBounds(170,50,150,20);
password.setBounds(170,80,150,20);
code.setBounds(170,110,150,20);
systemJPanel.add(a);
systemJPanel.add(b);
systemJPanel.add(c);
systemJPanel.add(username);
systemJPanel.add(password);
systemJPanel.add(code);
jframe.add(systemJPanel,"Center");

//按钮区域
JPanel buttonJPanel = new JPanel();
buttonJPanel.setLayout(new FlowLayout());
login.setFont(new Font("楷体",Font.BOLD,15));
reset.setFont(new Font("楷体",Font.BOLD,15));
buttonJPanel.add(login);
buttonJPanel.add(reset);
jframe.add(buttonJPanel, "South");

//设置背景
//JPanel bg = new JPanel();
//bg.setBackground(Color.pink);
//jframe.add(bg);
}
public static void main(String[] args) {
new Login1();
}

}
展开
 我来答
青春V笑
2018-01-14 · TA获得超过375个赞
知道小有建树答主
回答量:140
采纳率:63%
帮助的人:14.8万
展开全部

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式