天天看點

java中添加一個事件_java事件的添加

該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓

謝謝你   我想知道這個代碼每一行都是手寫的嗎 我的意思是說用NetBeans直接添加事件 隻要少寫一小部分代碼就可了 手寫的代碼怎麼添加 下面是我用NetBeans畫出界面生成的原代碼: (希望能懂我的意思 呵呵)

package Frame;

public class NewJFrame extends javax.swing.JFrame {

public NewJFrame() {

initComponents();

}

@SuppressWarnings("unchecked")

//

private void initComponents() {

jPasswordField2 = new javax.swing.JPasswordField();

jTextField2 = new javax.swing.JTextField();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton();

jTextField1 = new javax.swing.JTextField();

jButton2 = new javax.swing.JButton();

org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication4.DesktopApplication4.class).getContext().getResourceMap(NewJFrame.class);

jPasswordField2.setText(resourceMap.getString("jPasswordField2.text")); // NOI18N

jPasswordField2.setName("jPasswordField2"); // NOI18N

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setName("Form"); // NOI18N

jTextField2.setText(resourceMap.getString("jTextField2.text")); // NOI18N

jTextField2.setName("jTextField2"); // NOI18N

jTextField2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {