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

📄 jframe.java

📁 java 聊天室源码
💻 JAVA
字号:
package com.neworiental.mj.mingregister;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

import javax.swing.JOptionPane;

public class JFrame extends javax.swing.JFrame {
	/** Creates new form 新建JFrame */
	public JFrame() {
		initComponents();
	}

	/**
	 * 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.
	 */
	// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">
	private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel1.setFont(new java.awt.Font("Dialog", 1, 18));
        jLabel1.setForeground(new java.awt.Color(102, 102, 255));
        jLabel1.setText("\u6b22\u8fce\u6765\u5230\u660e\u6559\u804a\u5929\u5ba4");

        jLabel2.setFont(new java.awt.Font("Dialog", 0, 14));
        jLabel2.setText("\u7528\u6237\u540d");

        jLabel3.setFont(new java.awt.Font("Dialog", 0, 14));
        jLabel3.setText("\u5bc6\u7801");

        jButton1.setFont(new java.awt.Font("Dialog", 0, 14));
        jButton1.setText("\u6ce8\u518c");

        jButton2.setFont(new java.awt.Font("Dialog", 0, 14));
        jButton2.setText("\u767b\u9646");
        
        jButton1.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			mingregister regist = new mingregister();
    			
    			regist.setVisible( true);
    			JFrame.this.setVisible(false);
    		}
    	});
        
        jButton2.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				String str = readFile(jTextField1.getText() );
				if (str.equalsIgnoreCase( jTextField2.getText() ) ){
					JOptionPane.showMessageDialog( new JFrame(),"OK!");
					ClientChat cc = new ClientChat(jTextField1.getText().trim());
					cc.initComponent() ;
					JFrame.this.setVisible(false);
				}
				else{
					JOptionPane.showMessageDialog( new JFrame(),"error!");
				}
			}
        	
        });
        
      
        
     org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(101, 101, 101)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jLabel3)
                            .add(jLabel2)))
                    .add(layout.createSequentialGroup()
                        .add(90, 90, 90)
                        .add(jButton1)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(33, 33, 33)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jTextField2)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
                        .addContainerGap(84, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(86, 86, 86))))
            .add(layout.createSequentialGroup()
                .add(139, 139, 139)
                .add(jLabel1)
                .addContainerGap(149, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(46, 46, 46)
                .add(jLabel1)
                .add(48, 48, 48)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(23, 23, 23)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(35, 35, 35)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jButton2))
                .addContainerGap(45, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>
	
    public String readFile(String name) {
		try{
			File file = new File("d:\\yhxx.txt");
			if(!file.exists()){
				file.createNewFile();
			}
			Properties p = new Properties();
			InputStream is = new FileInputStream(file);
			p.load(is);
			return p.getProperty(name);
			
		}catch(Exception e){
			e.printStackTrace();
			return "";
		}
     }

         
	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new JFrame().setVisible(true);
			}
		});

	}

	public void controlAction() {

		String t1 = jTextField1.getText();
	}

	// 变量声明 - 不进行修改
	private javax.swing.JButton jButton1;

	private javax.swing.JButton jButton2;

	private javax.swing.JLabel jLabel1;

	private javax.swing.JLabel jLabel2;

	private javax.swing.JLabel jLabel3;

	private javax.swing.JTextField jTextField1;

	private javax.swing.JTextField jTextField2;
	// 变量声明结束

}

⌨️ 快捷键说明

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