十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
package pack_view;
为海湖新等地区用户提供了全套网页设计制作服务,及海湖新网站建设行业解决方案。主营业务为成都网站设计、做网站、海湖新网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.multi.MultiLookAndFeel;
import pack_DB.DB;
public class Login extends JFrame{
/**
* 登陆界面
*/
private static final long serialVersionUID = 1L;
JFrame jf = new JFrame();
private JPanel panel_all ;
private JPanel panel1 = new JPanel();
private JPanel panel2= new JPanel();
private JPanel panel3 = new JPanel();
private JPanel panel4 = new JPanel();
private JLabel jLabel_title;
private JLabel jLabel_name = new JLabel();
private JLabel jLabel_password = new JLabel();
private JTextField jTextField_name = new JTextField(15);
private JPasswordField jPasswordField = new JPasswordField(15);
private JButton jb1 = new JButton();
private JButton jb2 = new JButton();
private Font font;
String cid="";
String passwd ="";
//加载背景图片
// private ImageIcon imageicon;
// private Image image;
public Login() {
jf.setTitle("客户端登陆");
jf.setSize(350, 300);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();//把用户的显示器屏幕的尺寸(长和宽)赋值给变量screenSize
Dimension frameSize = jf.getSize();
if (frameSize.height screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width screenSize.width) {
frameSize.width = screenSize.width;
}
//把弹出的对话框窗口放置在屏幕中间
jf.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
// imageicon = new ImageIcon(ClassLoader
// .getSystemResource("res/backgound.jpg".toString()));
panel_all = new JPanel(){
public void paintComponent(Graphics g){
super.paintComponents(g);
// image = imageicon.getImage();
// if(image != null)
// g.drawImage(image,0,0,getWidth(),getHeight(),this);
}
};
font=new Font("宋体正文", 0,20);
jLabel_title = new JLabel(new ImageIcon(ClassLoader
.getSystemResource("res/Login.jpg".toString())));
jLabel_title.setFont(font);
jLabel_title.setText("用户登陆");
jLabel_name.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel_name.setText("用户名:");
jLabel_password.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel_password.setText("密 码:");
jb1.setFont(new java.awt.Font("Dialog", 0, 18));
jb1.setText("确 认");
jb2.setText("取 消");
jb2.setFont(new java.awt.Font("Dialog", 0, 18));
jTextField_name.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode()==KeyEvent.VK_ENTER)
{
jb1.doClick();
}
}});
jPasswordField.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode()==KeyEvent.VK_ENTER)
{
jb1.doClick();
}
}});
panel1.add(jLabel_name);
panel1.add(jTextField_name);
panel2.add(jLabel_password);
panel2.add(jPasswordField);
panel3.add(jb1);
panel3.add(jb2);
panel4.add(jLabel_title);
panel_all.setLayout(new GridLayout(4,1));
panel_all.add(panel4);
panel_all.add(panel1);
panel_all.add(panel2);
panel_all.add(panel3);
panel_all.setOpaque(false);
jf.setLayout(new BorderLayout());
jf.add(panel_all);
jb1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent me){
// if(lc.validate(jTextField_name.getText().trim(),new String(jPasswordField.getPassword()).trim())){
// doLogin();
// new MainFrame();
// }
// else
// JOptionPane.showMessageDialog(null, "Password doesn't match account,please try again!");
}
});
jb2.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent me){
System.exit(0);
}
});
jf.setVisible(true);
jf.repaint();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/* public void doLogin(){
cid=jTextField_name.getText().trim();
passwd=jPasswordField.getText().trim();
String sql = "select *from customer where "+"cid='"+cid+"' and password='"+passwd+"'";
if (DB.connectDB()) {
if (DB.query(sql)){
System.out.print("登陆成功");
jf.dispose();
new MainFrame(cid);
return;
} else {
System.out.print("登陆失败");
return;
}
}
}
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Login();
}
}
以下方法实现了用户界面登陆
import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用户名:");//使用文本创建一个用户名标签
TextField t1=new TextField();//创建一个文本框对象
Label password=new Label("密码:");//创建一个密码标签
TextField t2=new TextField();
Button b1=new Button("登陆");//创建登陆按钮
Button b2=new Button("取消");//创建取消按钮
public DengLuJieMian()
{
this.setTitle("学生信息管理系统");//设置窗口标题
this.setLayout(null);//设置窗口布局管理器
username.setBounds(50,40,60,20);//设置姓名标签的初始位置
this.add(username);// 将姓名标签组件添加到容器
t1.setBounds(120,40,80,20);// 设置文本框的初始位置
this.add(t1);// 将文本框组件添加到容器
password.setBounds(50,100,60,20);//密码标签的初始位置
this.add(password);//将密码标签组件添加到容器
t2.setBounds(120,100,80,20);//设置密码标签的初始位置
this.add(t2);//将密码标签组件添加到容器
b1.setBounds(50,150,60,20);//设置登陆按钮的初始位置
this.add(b1);//将登陆按钮组件添加到容器
b2.setBounds(120,150,60,20);//设置取消按钮的初始位置
this.add(b2);// 将取消按钮组件添加到容器
b1.addActionListener(this);//给登陆按钮添加监听器
b2.addActionListener(this);// 给取消按钮添加监听器
this.setVisible(true);//设置窗口的可见性
this.setSize(300,200);//设置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});//通过内部类重写关闭窗体的方法
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//处理登陆事件
{
String name=t1.getText();
String pass=t2.getText();
if(name!=nullpass.equals("000123"))//判断语句
{
new StudentJieMian();
}
}
}
public static void main(String args[])//主函数
{
new DengLuJieMian();
}
}
以下方法实现了学生界面设计
import java.awt.*;
import java.awt.event.*;
class StudentJieMian extends Frame implements ActionListener
{
MenuBar m=new MenuBar();//创建菜单栏
Menu m1=new Menu("信息");//创建菜单“信息”
MenuItem m11=new MenuItem("插入");//创建“插入”的菜单项
MenuItem m12=new MenuItem("查询");
Menu m2=new Menu("成绩");//创建菜单“成绩”
MenuItem m21=new MenuItem("查询");
public StudentJieMian()
{
this.setTitle("学生界面");//设置窗口标题
this.setLayout(new CardLayout());//设置窗口布局管理器
this.setMenuBar(m);//将菜单栏组件添加到容器
m.add(m1);//将信息菜单放入菜单栏
m.add(m2);
m1.add(m11);//将“插入”菜单项添加到“信息”菜单
m1.add(m12); //将“查询”菜单项添加到“信息”菜单
m2.add(m21); //将“查询”菜单项添加到“成绩”菜单
m11.addActionListener(this); //给“插入”菜单项添加监听器
m12.addActionListener(this); //给“查询”菜单项添加监听器
m21.addActionListener(this); //给“查询”菜单项添加监听器
this.setVisible(true); //设置窗口的可见性
this.setSize(300,200); //设置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);//关闭窗口
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11) //处理“添加信息”事件
{
new AddStudent();
}
if(e.getSource()==m12) //处理“查询信息”事件
{
new SelectStudent();
}
if(e.getSource()==m21) //处理“查询成绩”事件
{
new ChengJiStudent();
}
}
public static void main(String args[])
{ new StudentJieMian(); //创建一个对象 }
jsp:forward page=""/jsp:forward写上你要跳转的页面地址就可以了,这个jsp标准动作