日期:2014-05-20 浏览次数:20914 次
final JTextField jtf = new JTextField(20); JButton jbutton_ok = new JButton("ok!"); JButton jbutton_no = new JButton("no!"); jbutton_ok.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("ok!")){ System.out.println(jtf.getText());//不加final这里会报错 } } });
JButton jbutton_ok = new JButton("ok!"); JButton jbutton_no = new JButton("no!"); jbutton_ok.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("ok!")){ System.out.println(jtf.getText());//不加final这里会报错 } } }); //所有方法外 private javax.swing.JTextField jtf = new javax.swing.JTextField(20);