再看我的破JAVA的程序(接上一个,是关于给一个JButton加一个事件的问题)! (20分)

  • 主题发起人 主题发起人 易名烦
  • 开始时间 开始时间

易名烦

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下(事件没加上,出错):
import java.awt.*;
import javax.swing.*;
public class test extends JPanel{
private static JButton mm=new JButton();
private static JTextPane gg = new JTextPane();
public static void main(String args[]){
test ss = new test();
ss.setSize(100,100);
ss.setVisible(true);
gg.setText("My TextPane");
mm.setText("My Button");
ss.add(mm);
ss.add(gg);
ss.show();
mm.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e){
mm_actonPerformed(e);
}
});
JFrame sf = new JFrame();
sf.setBounds(0,0,300,400);
sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sf.getContentPane().add(ss);
sf.setTitle("My God!");
sf.setSize(800,600);
sf.show();
}
static void mm_actionPerformed(ActionEvent e){
gg.setText("请指教!");
}
}
谢谢先!
高手回答后可否留下联系方法,以后好请教!
这是编译错误信息:
--------------------Configuration: J2SDK1.4 <Default>--------------------
F:/JBuilder/test.java:27: cannot resolve symbol
symbol: method mm_actonPerformed (java.awt.event.ActionEvent)
mm_actonPerformed(e);
^
Note: F:/JBuilder/test.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
1 error
Process completed.
 
或者推荐一个好的JAVA的论谈也可以啊?
 
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2011</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;//add thsi ref
public class test extends JPanel{
private JButton mm=new JButton();
private JTextPane gg = new JTextPane();
public void mm_actonPerformed(ActionEvent e){
gg.setText("You Aredo
g!");
}
public test(){
this.setSize(100,100);
this.setVisible(true);
gg.setText("My TextPane");
mm.setText("My Button");
this.add(mm);
this.add(gg);
this.show();

mm.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e){
mm_actonPerformed(e);
}
});
JFrame sf = new JFrame();
sf.setBounds(0,0,300,400);
sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sf.getContentPane().add(this);
sf.setTitle("My God!");
sf.setSize(800,600);
sf.show();
}

public static void main(String args[]){
test ss = new test();
}
}
 
接受答案了.
 
后退
顶部