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

📄 login.java

📁 P2P聊天系统 该程序是由NetBeans IDE 6.5
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//* * login.java * * Created on 2009-2-28, 3:01:45 */package chatGUI;import java.awt.event.KeyEvent;import multicast.MultiCast;/** * * @author Administrator */public class login extends javax.swing.JFrame {    private boolean flag = true;    private String str = "";    /** Creates new form login */    public login() {        initComponents();        this.setLocation(400, 200);        this.setVisible(true);    }    /** 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.     */    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jPanel1 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        jtf = new javax.swing.JTextField();        jButton1 = new javax.swing.JButton();        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);        jLabel1.setFont(new java.awt.Font("宋体", 0, 18));        jLabel1.setText("请输入你的用户名:");        jtf.setFont(new java.awt.Font("宋体", 2, 18)); // NOI18N        jtf.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jtfActionPerformed(evt);            }        });        jtf.addKeyListener(new java.awt.event.KeyAdapter() {            public void keyPressed(java.awt.event.KeyEvent evt) {                jtfKeyPressed(evt);            }        });        jButton1.setFont(new java.awt.Font("宋体", 1, 14));        jButton1.setText("登入");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addGap(34, 34, 34)                        .addComponent(jLabel1))                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addGap(105, 105, 105)                        .addComponent(jtf, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addGap(151, 151, 151)                        .addComponent(jButton1)))                .addContainerGap(105, Short.MAX_VALUE))        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addGap(37, 37, 37)                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addComponent(jtf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(41, 41, 41)                .addComponent(jButton1)                .addContainerGap(42, Short.MAX_VALUE))        );        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)        );        pack();    }// </editor-fold>//GEN-END:initComponents    private void jtfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfActionPerformed        // TODO add your handling code here:}//GEN-LAST:event_jtfActionPerformed    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed        // TODO add your handling code here:        flag = false;        str = "login " + jtf.getText();        //System.out.println(str);        new MultiCast(str);        this.dispose();    }//GEN-LAST:event_jButton1ActionPerformed    private void jtfKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfKeyPressed        // TODO add your handling code here:        if(evt.getKeyCode()==KeyEvent.VK_ENTER){            flag = false;            str = "login " + jtf.getText();            //System.out.println(str);            new MultiCast(str);            this.dispose();        }    }//GEN-LAST:event_jtfKeyPressed    public String getusername(){        return jtf.getText();    }    public boolean getflag(){        return flag;    }    /**    * @param args the command line arguments    */    /*public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                login lg = new login();            }        });    }*/    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton jButton1;    private javax.swing.JLabel jLabel1;    private javax.swing.JPanel jPanel1;    private javax.swing.JTextField jtf;    // End of variables declaration//GEN-END:variables}

⌨️ 快捷键说明

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