易
易名烦
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.
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.