做了也快一周了,决定不做了。因为接下来要复习。等这阶段考试考完了,寒假我一定会拉出来再继续修改的。我做的是花店的管理系统,其实说相对还是比较简单的。主要的功能以及代码会在下面全部贴出。由于之前是在linux下面做的,后来又转回windows了。所以有一些不影响问题的中文乱码没有修改。是有一些懒啊。所用的数据库是sqlserver,数据库设计就不贴出来了,用的语言是java、做界面。以下所有代码纯手一字一字敲的。
首先是登陆界面,这个没有什么好说的,也是模拟qq的登录窗口
package com.zhong.panel;
//鐧诲綍鐣岄潰
import java.awt.Container;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
/**
* 鑺卞簵鐧诲綍鐣岄潰
*
* @author 閽熷織杩�
*/
public class LoginPanel extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
// 鐢ㄦ埛鍚�
private JTextField username;
// 瀵嗙爜
private JPasswordField password;
// 灏忓鍣�
private JLabel jl1;
private JLabel jl2;
private JLabel jl4;
// 灏忔寜閽�
private JButton bu1;
private JButton bu2;
// 澶嶉�夋
private JCheckBox jc1;
private JCheckBox jc2;
/*
* 鏋勯�犳柟娉�
*/
public LoginPanel() {
// 璁剧疆绐楀彛鏍囬
this.setTitle("花店后台登陆");
// 绐椾綋缁勪欢鍒濆鍖�
init();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 璁剧疆甯冨眬鏂瑰紡涓虹粷瀵瑰畾浣�
this.setLayout(null);
this.setBounds(0, 0, 355, 265);
// 璁剧疆绐椾綋鐨勬爣棰樺浘鏍�
Image image = new ImageIcon("e:/a.gif").getImage();
this.setIconImage(image);
// 绐椾綋澶у皬涓嶈兘鏀瑰彉
this.setResizable(false);
// 灞呬腑鏄剧ず
this.setLocationRelativeTo(null);
// 绐椾綋鍙
this.setVisible(true);
}
/*
* 鍒濆鍖栨柟娉�
*/
public void init() {
// 鍒涘缓涓�涓鍣�
Container con = this.getContentPane();
jl1 = new JLabel();
// 璁剧疆鑳屾櫙鍥剧墖
Image image1 = new ImageIcon("img/Login/login1.jpg").getImage();
jl1.setIcon(new ImageIcon(image1));
jl1.setBounds(0, 0, 355, 265);
// 鐧诲綍澶村儚璁惧畾
jl2 = new JLabel();
Image image2 = new ImageIcon("img/Login/login2.jpg").getImage();
jl2.setIcon(new ImageIcon(image2));
jl2.setBounds(30, 95, 60, 60);
// 鐢ㄦ埛鍙风爜鐧诲綍杈撳叆妗�
username = new JTextField();
username.setBounds(100, 100, 150, 20);
// 瀵嗙爜杈撳叆妗�
password = new JPasswordField();
password.setBounds(100, 130, 150, 20);
// 瀵嗙爜杈撳叆妗嗘梺杈圭殑鏂囧瓧
jl4 = new JLabel("自动登录");
jl4.setBounds(260, 130, 70, 20);
// 杈撳叆妗嗕笅鏂规枃瀛�
jc1 = new JCheckBox("记住密码");
jc1.setBounds(105, 155, 80, 15);
jc2 = new JCheckBox("忘记密码");
jc2.setBounds(185, 155, 80, 15);
// 鎸夐挳璁惧畾
bu1 = new JButton("登陆");
bu1.setBounds(280, 200, 65, 20);
// 缁欐寜閽坊鍔�1涓簨浠�
bu1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String user = username.getText().toString();
if(user.equals("admin")){
String getName =username.getText();
// String getPwd =password.getText();
JOptionPane.showConfirmDialog(null, "鎮ㄨ緭鍏ョ殑鐢ㄦ埛鍚嶆槸"+getName);
}
}
});
bu2 = new JButton("退出");
bu2.setBounds(5, 200, 75, 20);
bu2.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
});
// 鎵�鏈夌粍浠剁敤瀹瑰櫒瑁呰浇
jl1.add(jl2);
jl1.add(jl4);
jl1.add(jc1);
jl1.add(jc2);
jl1.add(bu1);
jl1.add(bu2);
con.add(jl1);
con.add(username);
con.add(password);
}
public static void main(String[] args){
new MainPanel();
}
}
主界面入口:
package com.zhong.panel;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MainPanel extends JFrame{
/**
* 主面板的入口
* author:小组
*/
private static final long serialVersionUID = 1L;
private JPanel main_panel;
public MainPanel(){
new GeneralPanel(main_panel,this).MakeGeneralPanel();
}
public void refresh(){
this.getContentPane().validate();
this.getContentPane().repaint();
}
}
进入主界面之后主面板,以下一张截图对应一段代码(很丑啊,尽情吐槽,毕竟不会美工,没有美工):
package com.zhong.panel;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class MainshowPanel extends JPanel {
/**
* 后台管理的展示页面
*/
private JLabel lb_back;
private static final long serialVersionUID = 1L;
public MainshowPanel(){
init();
}
public void init(){
lb_back = new JLabel();
Image image = new ImageIcon("img/back.jpg").getImage();
lb_back.setIcon(new ImageIcon(image));
this.add(lb_back);
this.setVisible(true);
}
}
package com.zhong.panel;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.zhong.DAO.FlowerDao;
import com.zhong.tools.PicTransparent;
public class GeneralPanel{
/**
*通用面板
* author:组
*/
private JPanel left_panel;
private JLabel left_back_label;
private JButton btn_main;
private JButton btn_edit;
private JButton btn_report;
private JButton btn_exit;
private JButton btn_order;
private JButton btn_member;
private JPanel top_panel;
private JLabel top_back_label;
private JTextField tf_find;
private JButton btn_find;
private JButton btn_export;
private JPanel main_panel;
private JFrame frame;
private FlowerDao flower;
private Object[] obj;
private PicTransparent pic;
@SuppressWarnings("unused")
private String str;//鐢ㄦ潵璁板綍褰撳墠鏄剧ず鐨勫摢涓�涓潰鏉�
private