https://download.csdn.net/download/qq_47168235/87881728
https://pan.baidu.com/s/1Gd-H5XZtzhmaqVgRAYd7aA?pwd=slev
【注:百度网盘里有我所有资源,请按需下载】
https://pan.baidu.com/s/1ja7oAdIg5ktm87Ta0arswA?pwd=kcyo
/*
* CustomerAddInterFrm.java
*
* Created on __DATE__, __TIME__
*/
package com.view;
import java.sql.Connection;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
import com.dao.CustomerUserDao;
import com.dao.ProductChosenDao;
import com.model.Customer;
import com.util.Dbutil;
import com.util.StringUtil;
/**
*
* @author __USER__
*/
public class CustomerAddInterFrm extends javax.swing.JInternalFrame {
Dbutil dbutil = new Dbutil();
CustomerUserDao customerUserDao=new CustomerUserDao();
ProductChosenDao productChosenDao = new ProductChosenDao();
/** Creates new form CustomerAddInterFrm */
public CustomerAddInterFrm() {
initComponents();
this.setLocation(200, 100);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
userNameTxt = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
password1Txt = new javax.swing.JPasswordField();
jLabel3 = new javax.swing.JLabel();
password2Txt = new javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
moneyTxt = new javax.swing.JTextField();
jb_Add = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jLabel1.setText("\u7528\u6237\u540d");
jLabel2.setText("\u5bc6\u7801");
jLabel3.setText("\u5bc6\u7801");
jLabel4.setText("\u5b58\u5165\u91d1\u989d");
jb_Add.setText("\u6ce8\u518c");
jb_Add.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_AddActionPerformed(evt);
}
});
setClosable(true);
jLabel5.setFont(new java.awt.Font("微软雅黑", 0, 24));
jLabel5.setText("\u6ce8\u518c\u65b0\u4f1a\u5458");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout
.setHorizontalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGap(56, 56, 56)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(35, 35, 35)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jLabel5)
.addComponent(
password1Txt)
.addComponent(
userNameTxt,
javax.swing.GroupLayout.DEFAULT_SIZE,
167,
Short.MAX_VALUE)
.addComponent(
password2Txt)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(
jb_Add)
.addComponent(
moneyTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
84,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(88, Short.MAX_VALUE)));
layout
.setVerticalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
layout
.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(
jLabel5,
javax.swing.GroupLayout.DEFAULT_SIZE,
38, Short.MAX_VALUE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(
userNameTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(
password1Txt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(
password2Txt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(
moneyTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jb_Add).addContainerGap()));
pack();
}//
//GEN-END:initComponents
private void jb_AddActionPerformed(java.awt.event.ActionEvent evt) {
String customerName=this.userNameTxt.getText();
String password1=new String(this.password1Txt.getPassword());
String password2=new String(this.password2Txt.getPassword());
String money=this.moneyTxt.getText();
if (StringUtil.isEmpty( customerName)) {
JOptionPane.showMessageDialog(null, "用户名不能为空");
return;
}
if (StringUtil.isEmpty(password1)) {
JOptionPane.showMessageDialog(null, "密码不能为空");
return;
}
if(!password2.equals(password1)){
JOptionPane.showMessageDialog(null, "两次密码要相同");
return;
}
if (Float.parseFloat(money)<=0) {
JOptionPane.showMessageDialog(null, " 存入金钱数需为正!");
return;
}
Customer customer=new Customer( customerName, password1,
password2, Float.parseFloat(money) );
Connection con=null;
try {
con=dbutil.getCon();
//搜索是否存在相同的用户名
ResultSet rs = productChosenDao.customerList(con, customer);
while(rs.next()){
String customerName1=rs.getString("customerName");
if(customerName.equals(customerName1)){
JOptionPane.showMessageDialog(null, "用户名已存在!");
return;
}}
con = dbutil.getCon();
int addNum=customerUserDao.customerAdd(con, customer);
if(addNum==1){
JOptionPane.showMessageDialog(null, "注册成功");
this.dispose();
}else{
JOptionPane.showMessageDialog(null, "注册失败");
}
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "注册失败");
}finally{
try {
dbutil.closeCon(con);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JButton jb_Add;
private javax.swing.JTextField moneyTxt;
private javax.swing.JPasswordField password1Txt;
private javax.swing.JPasswordField password2Txt;
private javax.swing.JTextField userNameTxt;
// End of variables declaration//GEN-END:variables
}
/*
* MainFrm.java
*
* Created on __DATE__, __TIME__
*/
package com.view;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
*
* @author __USER__
*/
public class MainFrm extends javax.swing.JFrame {
/** Creates new form MainFrm */
public MainFrm() {
initComponents();
//设置最大 化
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
//
private void initComponents() {
table = new javax.swing.JDesktopPane();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu3 = new javax.swing.JMenu();
jmiProductTypeAdd = new javax.swing.JMenuItem();
jmiProductTypeModify = new javax.swing.JMenuItem();
jMenu4 = new javax.swing.JMenu();
jmiProductAdd = new javax.swing.JMenuItem();
jmiProductModify = new javax.swing.JMenuItem();
jmiExit = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem6 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("\u8d2d\u7269\u7cfb\u7edf\u4e3b\u754c\u9762");
jMenu1.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\base.png"))); // NOI18N
jMenu1.setText("\u57fa\u672c\u6570\u636e\u7ef4\u62a4");
jMenu3.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\manager.gif"))); // NOI18N
jMenu3.setText("\u5546\u54c1\u79cd\u7c7b\u7ba1\u7406");
jmiProductTypeAdd.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\add.png"))); // NOI18N
jmiProductTypeAdd.setText("\u5546\u54c1\u7c7b\u522b\u6dfb\u52a0");
jmiProductTypeAdd
.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmiProductTypeAddActionPerformed(evt);
}
});
jMenu3.add(jmiProductTypeAdd);
jmiProductTypeModify.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\modify.gif"))); // NOI18N
jmiProductTypeModify.setText("\u5546\u54c1\u7c7b\u522b\u7ef4\u62a4");
jmiProductTypeModify
.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmiProductTypeModifyActionPerformed(evt);
}
});
jMenu3.add(jmiProductTypeModify);
jMenu1.add(jMenu3);
jMenu4
.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\product manager.gif"))); // NOI18N
jMenu4.setText("\u5546\u54c1\u7ba1\u7406");
jmiProductAdd.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\shopadd.gif"))); // NOI18N
jmiProductAdd.setText("\u5546\u54c1\u6dfb\u52a0");
jmiProductAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmiProductAddActionPerformed(evt);
}
});
jMenu4.add(jmiProductAdd);
jmiProductModify.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\modify.gif"))); // NOI18N
jmiProductModify.setText("\u5546\u54c1\u7ef4\u62a4");
jmiProductModify.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmiProductModifyActionPerformed(evt);
}
});
jMenu4.add(jmiProductModify);
jMenu1.add(jMenu4);
jmiExit.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\exit.png"))); // NOI18N
jmiExit.setText("\u9000\u51fa\u7cfb\u7edf");
jmiExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmiExitActionPerformed(evt);
}
});
jMenu1.add(jmiExit);
jMenuBar1.add(jMenu1);
jMenu2.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\about.png"))); // NOI18N
jMenu2.setText("\u5173\u4e8e\u6211\u4eec");
jMenuItem6.setIcon(new javax.swing.ImageIcon(MainFrm.class.getResource(
"/images\\me.png"))); // NOI18N
jMenuItem6.setText("\u5173\u4e8e\u7f51\u7ad9");
jMenu2.add(jMenuItem6);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addComponent(table,
javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addComponent(table,
javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE));
pack();
}//
//GEN-END:initComponents
private void jmiProductModifyActionPerformed(java.awt.event.ActionEvent evt) {
ProductManageInterFrm ProductManageInterFrm = new ProductManageInterFrm();
ProductManageInterFrm.setVisible(true);
this.table.add(ProductManageInterFrm);
}
private void jmiProductAddActionPerformed(java.awt.event.ActionEvent evt) {
ProductAddInterFrm ProductAddInterFrm = new ProductAddInterFrm();
ProductAddInterFrm.setVisible(true);
this.table.add(ProductAddInterFrm);
}
private void jmiProductTypeModifyActionPerformed(
java.awt.event.ActionEvent evt) {
ProductTypeManageInterFrm ProductTypeManageInterFrm = new ProductTypeManageInterFrm();
ProductTypeManageInterFrm.setVisible(true);
this.table.add(ProductTypeManageInterFrm);
}
private void jmiProductTypeAddActionPerformed(java.awt.event.ActionEvent evt) {
ProductTypeInterFrm productTypeInterFrm = new ProductTypeInterFrm();
productTypeInterFrm.setVisible(true);
this.table.add(productTypeInterFrm);
}
private void jmiExitActionPerformed(java.awt.event.ActionEvent evt) {
int result = JOptionPane.showConfirmDialog(null, "是否退出系统");
if (result == 0) {
this.dispose();//观看它的传值然后定义变量
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainFrm().setVisible(true);
}
});
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jmiExit;
private javax.swing.JMenuItem jmiProductAdd;
private javax.swing.JMenuItem jmiProductModify;
private javax.swing.JMenuItem jmiProductTypeAdd;
private javax.swing.JMenuItem jmiProductTypeModify;
private javax.swing.JDesktopPane table;
// End of variables declaration//GEN-END:variables
}
/*
* ManagerLogOnFrm.java
*
* Created on __DATE__, __TIME__
*/
package com.view;
import java.awt.Font;
import java.sql.Connection;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import com.dao.ManagerUserDao;
import com.model.ManagerUser;
import com.util.Dbutil;
import com.util.StringUtil;
/**
*
* @author __USER__
*/
public class ManagerLogOnFrm extends javax.swing.JFrame {
Dbutil dbUtil = new Dbutil();
ManagerUserDao managerUserDao = new ManagerUserDao();
/** Creates new form ManagerLogOnFrm */
public ManagerLogOnFrm() {
//改变系统默认字体
Font font = new Font("Dialog", Font.PLAIN, 12);
java.util.Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get(key);
if (value instanceof javax.swing.plaf.FontUIResource) {
UIManager.put(key, font);
}
}
initComponents();
//设置frame居中显示
this.setLocationRelativeTo(null);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
userNameTxt = new javax.swing.JTextField();
passwordTxt = new javax.swing.JPasswordField();
jb_logon = new javax.swing.JButton();
jb_reset = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 24));
jLabel1.setText("\u7ba1\u7406\u5458\u767b\u9646");
jLabel2.setIcon(new javax.swing.ImageIcon(ManagerLogOnFrm.class.getResource(
"/images/userName.png"))); // NOI18N
jLabel2.setText("\u7528\u6237\u540d");
jLabel3.setIcon(new javax.swing.ImageIcon(ManagerLogOnFrm.class.getResource(
"/images\\password.png"))); // NOI18N
jLabel3.setText("\u5bc6\u7801");
userNameTxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
userNameTxtActionPerformed(evt);
}
});
jb_logon.setIcon(new javax.swing.ImageIcon(ManagerLogOnFrm.class.getResource(
"/images\\login.png"))); // NOI18N
jb_logon.setText("\u767b\u9646");
jb_logon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_logonActionPerformed(evt);
}
});
jb_reset.setIcon(new javax.swing.ImageIcon(ManagerLogOnFrm.class.getResource(
"/images\\reset.png"))); // NOI18N
jb_reset.setText("\u91cd\u7f6e");
jb_reset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_resetActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout
.setHorizontalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup().addContainerGap(
148, Short.MAX_VALUE).addComponent(
jLabel1).addGap(132, 132, 132))
.addGroup(
layout
.createSequentialGroup()
.addGap(75, 75, 75)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGap(
25,
25,
25)
.addComponent(
jb_logon)
.addGap(
52,
52,
52)
.addComponent(
jb_reset))
.addGroup(
layout
.createSequentialGroup()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jLabel2)
.addComponent(
jLabel3))
.addGap(
35,
35,
35)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(
passwordTxt)
.addComponent(
userNameTxt,
javax.swing.GroupLayout.DEFAULT_SIZE,
161,
Short.MAX_VALUE))))
.addGap(73, 73, 73)));
layout
.setVerticalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jLabel1)
.addGap(39, 39, 39)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(
userNameTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(
passwordTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(39, 39, 39)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jb_logon)
.addComponent(jb_reset))
.addContainerGap(60, Short.MAX_VALUE)));
pack();
}//
//GEN-END:initComponents
private void jb_logonActionPerformed(java.awt.event.ActionEvent evt) {
//首先要获取页面上 的信息。
String userName = userNameTxt.getText();
String password = new String(passwordTxt.getPassword());
if (StringUtil.isEmpty(userName)) {
JOptionPane.showMessageDialog(null, "用户名不能为空");
return;
}
if (StringUtil.isEmpty(password)) {
JOptionPane.showMessageDialog(null, "密码不能为空");
return;
}
ManagerUser managerUser = new ManagerUser(userName, password);
Connection con = null;
try {
con = dbUtil.getCon();
ManagerUser currentManagerUser = managerUserDao.login(con,
managerUser);
if (currentManagerUser != null) {
this.dispose();
new MainFrm().setVisible(true);
} else {
JOptionPane.showMessageDialog(null, "用户名或密码错误");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "登陆失败");
} finally {
try {
dbUtil.closeCon(con);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private void jb_resetActionPerformed(java.awt.event.ActionEvent evt) {
this.userNameTxt.setText("");
this.passwordTxt.setText("");
}
private void userNameTxtActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ManagerLogOnFrm().setVisible(true);
}
});
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JButton jb_logon;
private javax.swing.JButton jb_reset;
private javax.swing.JPasswordField passwordTxt;
private javax.swing.JTextField userNameTxt;
// End of variables declaration//GEN-END:variables
}
/*
* ViewMainFrm.java
*
* Created on __DATE__, __TIME__
*/
package com.view;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.UIManager;
/**
*
* @author __USER__
*/
public class ViewMainFrm extends javax.swing.JFrame {
/** Creates new form ViewMainFrm */
public ViewMainFrm() {
//改变系统默认字体
Font font = new Font("Dialog", Font.PLAIN, 12);
java.util.Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get(key);
if (value instanceof javax.swing.plaf.FontUIResource) {
UIManager.put(key, font);
}
}
initComponents();
//设置frame居中显示
this.setLocationRelativeTo(null);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jb_viewProduct = new javax.swing.JButton();
jb_ManagetLogOn = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 36));
jLabel1.setText("\u6b22\u8fce\u6765\u5230\u5546\u57ce");
jb_viewProduct.setText("\u6d4f\u89c8\u5546\u54c1");
jb_viewProduct.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_viewProductActionPerformed(evt);
}
});
jb_ManagetLogOn.setText("\u7ba1\u7406\u5458\u767b\u9646");
jb_ManagetLogOn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_ManagetLogOnActionPerformed(evt);
}
});
jButton3.setText("\u65b0\u4f1a\u5458\u6ce8\u518c");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_viewProductActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGroup(
layout.createSequentialGroup().addContainerGap(111,
Short.MAX_VALUE).addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 301,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()).addGroup(
layout.createSequentialGroup().addGap(27, 27, 27).addComponent(
jb_viewProduct).addGap(57, 57, 57).addComponent(
jb_ManagetLogOn).addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51,
Short.MAX_VALUE).addComponent(jButton3).addGap(22, 22,
22)));
layout
.setVerticalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(
jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
132,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jb_viewProduct)
.addComponent(
jb_ManagetLogOn)
.addComponent(jButton3))
.addContainerGap(87, Short.MAX_VALUE)));
pack();
}//
//GEN-END:initComponents
private void jb_viewProductActionPerformed(java.awt.event.ActionEvent evt) {
new FuntionMainFrm().setVisible(true);
}
private void jb_ManagetLogOnActionPerformed(java.awt.event.ActionEvent evt) {
new ManagerLogOnFrm().setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ViewMainFrm().setVisible(true);
}
});
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton jb_ManagetLogOn;
private javax.swing.JButton jb_viewProduct;
// End of variables declaration//GEN-END:variables
}
https://so.csdn.net/so/search?q=java%20swing&t=blog&u=qq_47168235
所有代码均经过多次测试,放心下载,资源已在本文置顶。