⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regist.java

📁 java开发的大整数计算器,实现基本的运算,还有sin,cos,tan,cot.
💻 JAVA
字号:
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;


public class Regist extends JFrame
{
	private JTextField userName,userPsw;
	private JButton cancel,submit;
	private JPanel namePanel,pswPanel,buttonPanel,mainPanel;
	
	public Regist()
	{
		super("注册");
		
		userName = new JTextField("");
		userPsw = new JTextField("");
		
		cancel = new JButton("取消");
		submit = new JButton("提交");
		
		namePanel = new JPanel(new BorderLayout());
		pswPanel = new JPanel(new BorderLayout());
		buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER,5,0));
		mainPanel = new JPanel(new GridLayout(2,1));
		
		namePanel.add(new JLabel("用户名:",JLabel.RIGHT),BorderLayout.WEST);
		namePanel.add(userName);
		
		pswPanel.add(new JLabel("    密码:",JLabel.RIGHT),BorderLayout.WEST);
		pswPanel.add(userPsw);
		
		mainPanel.add(this.namePanel);
		mainPanel.add(this.pswPanel);
		
		buttonPanel.add(submit);
		buttonPanel.add(cancel);
		
		this.add(mainPanel);
		this.add(buttonPanel,BorderLayout.SOUTH);
		this.pack();
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		
		submit.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				String userNameString = userName.getText(),
						userPswString = userPsw.getText();
				
				if(userNameString.length() < 1 || userPswString.length() < 1 )
					
					JOptionPane.showMessageDialog(null,"用户名与密码不能为空");
				
				else if(userNameString.length() < 8)
					
					JOptionPane.showMessageDialog(null,"用户名长度不能小于8位");
				
				else if(userPswString.length() < 6)
					JOptionPane.showMessageDialog(null,"密码长度不能小于6位");
				
				else
				{
					SqlStatment s = new SqlStatment();
					
					int flag = s.RegistUser(userNameString,userPswString);
					
					if(flag == 0)
					{
						JOptionPane.showMessageDialog(null,"注册成功!");
						hideFrame();
					}
					else
						JOptionPane.showMessageDialog(null,"注册失败,用户名已存在!");
				}
			}
			
		});
		
		cancel.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				hideFrame();
			}
			
		});
	}
	
	private void hideFrame()
	{
		this.setVisible(false);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -