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

📄 enter.java

📁 小生用Java写了一个文本编辑器
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import sun.audio.*;
import java.io.FileInputStream;
public class Enter extends JDialog implements ActionListener
{
	private JTextField jtf01;
	private JPasswordField jpf;
	private JButton jb01,jb02,jb03;
	private JLabel jlzh,jl01,jl02;
	private JPanel jp01,jp03,jp05;
	public Enter()
	{	
		jlzh = new JLabel("您可以使用以下帐号进入:yuzhixun,fengzi,showyu;密码:123456");
		jtf01 = new JTextField(8);
		jpf = new JPasswordField(8);
		jl01 = new JLabel("用户名:");
		jl02 = new JLabel("密码:");
		jpf.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				Enter.this.chuanjian();
			}
			
		});
		jb01 = new JButton("登录");
		jb01.addActionListener(this);
		jb02 = new JButton("取消");
		jb02.addActionListener(this);
		jb03 = new JButton("退出");
		jb03.addActionListener(this);
		jp01 = new JPanel();
		jp01.add(jlzh);
		jp05 = new JPanel();
		jp05.add(jl01);jp05.add(jtf01);jp05.add(jl02);jp05.add(jpf);
		jp03 = new JPanel();
		jp03.add(jb01);jp03.add(jb02);jp03.add(jb03);
		Container con = getContentPane();
		con.setLayout(new GridLayout(3,1));
		con.add(jp01);con.add(jp05);con.add(jp03);
		pack();
		setResizable(false);
		setLocation(300,300);
		setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
		setVisible(true);
	}
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==jb01)
		{
			String str = jtf01.getText();
			char a[] = jpf.getPassword();
			String str01 = new String(a);
			if((str.equals("yuzhixun")||str.equals("fengzi")||str.equals("showyu"))&&(str01.equals("123456")))
			{
				new WordTextFrame();
                this.dispose();
			}
			else
			{
				AudioStream music = null;
		        try
		        {
		              music = new AudioStream(new FileInputStream("system.wav"));
		              AudioPlayer.player.start(music);
                      JOptionPane.showMessageDialog(this,"用户名或密码有误,请重试!!!","信息",JOptionPane.INFORMATION_MESSAGE);
                	  AudioPlayer.player.stop(music);
                	  music.close();
		        } catch (Exception exa)
                {exa.printStackTrace();}
			}
			
		}
		else if(e.getSource()==jb02)
		{
			jtf01.setText("");
			jtf01.requestFocus();
			AudioStream music = null;
			int i = 0;
				try
		        {
		              music = new AudioStream(new FileInputStream("jay.wav"));
		              AudioPlayer.player.start(music);
                      JOptionPane.showMessageDialog(this,"用户名或密码有误,请重试!!!","信息",JOptionPane.INFORMATION_MESSAGE);
                	  AudioPlayer.player.stop(music);
                	  music.close();
		        } catch (Exception exa)
                {exa.printStackTrace();}
                
		}
		else
		{
			System.exit(0);
		}
		
		
	}
	public void chuanjian()
	{
		String str = jtf01.getText();
		char a[] = jpf.getPassword();
		String str01 = new String(a);
		if((str.equals("yuzhixun")||str.equals("fengzi")||str.equals("showyu"))&&(str01.equals("123456")))
			{
				new WordTextFrame();
				this.dispose();
			}
		else
		{
			AudioStream music = null;
		        try
		        {
		              music = new AudioStream(new FileInputStream("system.wav"));
		              AudioPlayer.player.start(music);
                    //AudioPlayer.player.wait();
                    JOptionPane.showMessageDialog(this,"用户名或密码有误,请重试!!!","信息",JOptionPane.INFORMATION_MESSAGE);
					AudioPlayer.player.stop(music);
					music.close();
		        } catch (Exception exa)
                {exa.printStackTrace();}
        }
			
	}
	
}

⌨️ 快捷键说明

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