58,453
社区成员
发帖
与我相关
我的任务
分享
/**
* 这是学生登陆后的界面
*/
package nwpu.bms.view;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.imageio.*;//导入图片的包
import java.io.*;
import nwpu.bms.model.*;
import nwpu.bms.view.UserLogin.BackImage;
public class StuManage extends JDialog implements ActionListener {
JLabel jl1;
JButton jSeaBook, jPerInf, jQuit;//图书检索和查看个人信息按钮
Font f1=new Font("楷体",Font.PLAIN,26);//设置字体
Font f2=new Font("宋体",Font.PLAIN,18);
public static void main(String[] args)
{
StuManage sm=new StuManage();
}
public StuManage()
{
Container ct=this.getContentPane();
//创建各个组件
jl1=new JLabel("西北工业大学图书馆系统1.0");
jl1.setFont(f2);//把jl1的字体设置为f1
jl1.setBounds(370,540,320,50);
//放入
ct.add(jl1);
jSeaBook=new JButton("图书检索");
jSeaBook.addActionListener(this);//监听
jSeaBook.setFont(f1);
jSeaBook.setBounds(435,255,150,50);
ct.add(jSeaBook);
jPerInf=new JButton("个人信息");
jPerInf.addActionListener(this);//监听
jPerInf.setFont(f1);
jPerInf.setBounds(435,395,150,50);
ct.add(jPerInf);
jQuit=new JButton("注销");
jQuit.addActionListener(this);//监听
jQuit.setFont(f2);
jQuit.setBounds(225,25,70,30);
ct.add(jQuit);
this.setLayout(null);//空布局
//创建一个BackImage对象
BackImage bi=new BackImage();
//把图片位置确定
bi.setBounds(0,0,1024,576);//前两个参数表示从空布局左上角计算,后两个参数是文件的大小
//也可以这样子做
ct.add(bi);
this.setUndecorated(true);
this.setSize(1024,576);
//确定JWindowde的初始位置
this.setLocationRelativeTo(null);//窗口居中
this.setVisible(true);
}
//内部类
class BackImage extends JPanel
{
Image im;
public BackImage()
{
try {
im=ImageIO.read(new File("image//stumanage.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void paintComponent (Graphics g)
{
g.drawImage(im, 0, 0, 1033, 644, this);
}
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//点击注销关闭本窗口,进入登陆界面
if(e.getSource()==jQuit)
{
new UserLogin();
this.dispose();
}
}
}