《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
stmt = connection.createStatement();
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} // 链接数据库
}
/**
-
This method initializes this
-
@return void
*/
private void initialize() {
// 登录窗口大小
this.setSize(500, 308);
this.setContentPane(getJContentPane());
this.setTitle(“欢迎登录教材管理系统”);
}
// 登录函数
private void denglu() {
if (flag > 2) {
jButton.setEnabled(false);
}
this.jLabel.setText(“登录中请稍候。。”);
username = jTextField.getText();
String pwd = String.valueOf(jPasswordField.getPassword());
String yz = new String(“Select username,pswd,yanzheng from login where username='” + username + “'”);
try {
ResultSet result = stmt.executeQuery(yz);
if (result.next()) { // 用户名存在~
if (pwd.equals(result.getString(2))) {
if (result.getString(3).equals(“1”)) { // 验证权限
this.jLabel.setText(" 登录成功");
this.flag = 1; // 若取得数据的第三项是1的话,则把flag设置为1
this.setVisible(false);
XFlashScreen splash = new XFlashScreen();
splash.start(); // 运行启动界面
} else if (result.getString(3).equals(“4”)) { // 验证权限
this.jLabel.setText(" 登录成功");
this.flag = 4; // 若取得数据的第三项是4的话,则把flag设置为4
this.setVisible(false);
}
} else {
this.jLabel.setText(" 密码错误 -_-!");
flag++;
}
} else {
this.jLabel.setText(" 没有此用户 -_-!");
flag++;
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
/**
-
This method initializes jContentPane
-
@return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(160, 55, 57, 17));
jLabel1.setText(“账号:”);
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(160, 100, 55, 17));
jLabel2.setText(“密码:”);
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(180, 150, 177, 14));
jLabel.setText("不能尝试超过4次哦~(__) ");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setBackground(new Color(255, 255, 225));
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(jLabel, null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJPasswordField(), null);
}
return jContentPane;
}
public void windowActivated(WindowEvent arg0) {
}
public void windowClosed(WindowEvent arg0) {
System.exit(0);
}
public void windowClosing(WindowEvent arg0) {
}
public void windowDeactivated(WindowEvent arg0) {
}
public void windowDeiconified(WindowEvent arg0) {
}
public void windowIconified(WindowEvent arg0) {
}
public void windowOpened(WindowEvent arg0) {
}
/**
-
This method initializes jButton
-
@return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton(new ImageIcon(“./pic/key.gif”));
jButton.setBounds(new Rectangle(120, 180, 83, 25));
// jButton.setFont(new Font(“Dialog”, Font.BOLD, 11));
jButton.setText(“登录”);
jButton.addActionListener(this);
}
return jButton;
}
/**
-
This method initializes jButton1
-
@return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton(new ImageIcon(“./pic/exit.gif”));
jButton1.addActionListener(this);
jButton1.setBounds(new Rectangle(300, 180, 83, 25));
// jButton1.setFont(new Font(“Dialog”, Font.BOLD, 11));
jButton1.setText(“退出”);
}
return jButton1;
}
/**
-
This method initializes jTextField
-
@return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(200, 45, 156, 35));
jTextField.addKeyListener(this);
}
return jTextField;
}
/**
-
This method initializes jPasswordField
-
@return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField() {
if (jPasswordField == null) {
jPasswordField = new JPasswordField();
jPasswordField.setBounds(new Rectangle(200, 90, 156, 35));
jPasswordField.addKeyListener(this);
}
return jPasswordField;
}
public void actionPerformed(ActionEvent e) {
if ((JButton) e.getSource() == jButton1) {
this.dispose();
System.exit(0);
} else if ((JButton) e.getSource() == jButton) {
denglu();
}
}
public void keyPressed(KeyEvent arg0) {
}
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER)/** 判断是否回车 */
denglu();
}
public void keyTyped(KeyEvent arg0) {
}
public static void main(String[] args) {
Login aaa = new Login();
aaa.setVisible(true);
}
}
package com.sjsq;
import javax.swing.table.AbstractTableModel;
class MyTable extends AbstractTableModel {
Object[][] p = null;
String[] n = null;
MyTable(Object[][] p, String[] n) {
this.p = p;
this.n = n;
}
public int getColumnCount() {
return n.length;
}
public int getRowCount() {
return p.length;
}
public Object getValueAt(int row, int col) {
return p[row][col];
}
public String getColumnName(int col) {
return n[col];
}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public boolean isCellEditable(int row, int col) {
if (col == 0) {
return false;
} else {
return true;
}
}
public void setValueAt(Object value, int row, int col) {
{
p[row][col] = value;
}
}
}
package com.sjsq;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
public class XMainFrame extends JFrame implements WindowListener {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JTabbedPane jTabbedPane = null;
XAddForm xaddform;
/**
- This is the default constructor
*/
public XMainFrame() {
super();
xaddform = new XAddForm();
initialize();
Dimension screen = getToolkit().getScreenSize(); // 得到屏幕尺寸
// pack(); //窗口适应组件尺寸
setLocation((screen.width - 800) / 2, (screen.height - 600) / 2);
}
/**
-
This method initializes this
-
@return void
*/
private void initialize() {
this.setSize(567, 401);
this.setContentPane(getJContentPane());
this.setTitle(“教材管理系统”);
}
/**
-
This method initializes jContentPane
-
@return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.gridwidth = -1;
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.ipadx = -5;
gridBagConstraints.ipady = -7;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.gridheight = -1;
jContentPane = new JPanel();
jContentPane.setLayout(new GridBagLayout());
jContentPane.add(getJTabbedPane(), gridBagConstraints);
}
return jContentPane;
}
/**
-
This method initializes jTabbedPane
-
@return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
xaddform.setBounds(new Rectangle(1, 2, 558, 366));
jTabbedPane.addTab(“表单提交”, null, xaddform, null);
}
return jTabbedPane;
}
public void windowActivated(WindowEvent arg0) {
// TODO 自动生成方法存根
}
public void windowClosed(WindowEvent arg0) {
// TODO 自动生成方法存根
}
public void windowClosing(WindowEvent arg0) {
// TODO 自动生成方法存根
System.exit(0);
}
public void windowDeactivated(WindowEvent arg0) {
// TODO 自动生成方法存根
}
public void windowDeiconified(WindowEvent arg0) {
// TODO 自动生成方法存根
}
public void windowIconified(WindowEvent arg0) {
// TODO 自动生成方法存根
}
public void windowOpened(WindowEvent arg0) {
// TODO 自动生成方法存根
}
}
===================================================================
Java+JSP系统系列实现
Java+Servlet+JSP系统系列实现
Java+SSM系统系列实现
Java+SSM+Bootstrap+Maven实现网上书城系统
Java+SSM+Bootstrap+Maven实现学校教务管理系统
Java+SSH系统系列实现
Java+Springboot系统系列实现
Java+Springboot+Bootstrap实现网上商城系统
Java+Springboot+Bootstrap+Maven实现景区旅游管理系统
JavaSwing+Mysql系统系列实现
最后
给大家送一个小福利
附高清脑图,高清知识点讲解教程,以及一些面试真题及答案解析。送给需要的提升技术、准备面试跳槽、自身职业规划迷茫的朋友们。
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
统]( )
Java+SSM+Bootstrap+Maven实现学校教务管理系统
Java+SSH系统系列实现
Java+Springboot系统系列实现
Java+Springboot+Bootstrap实现网上商城系统
Java+Springboot+Bootstrap+Maven实现景区旅游管理系统
JavaSwing+Mysql系统系列实现
最后
给大家送一个小福利
[外链图片转存中…(img-lsbp0Mct-1714474892422)]
附高清脑图,高清知识点讲解教程,以及一些面试真题及答案解析。送给需要的提升技术、准备面试跳槽、自身职业规划迷茫的朋友们。
[外链图片转存中…(img-32YFJxR9-1714474892422)]
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!