JAVA编程Unicode译码器出现问题
代码如下,但结果提示ThetypeQueryFramemustimplementtheinheritedabstractmethodActionListener.acti...
代码如下,但结果提示
The type QueryFrame must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent),新手求指导。
import java.awt.*;
import java.awt.event.*;
public class QueryFrame extends Frame implements ActionListener
{
private TextField text_char,text_uni;
private Button button_char,button_uni;
public QueryFrame()
{
super("Unicode字符查询器");
this.setBounds(300, 240, 280, 90);
this.setBackground(Color.lightGray);
this.setLayout(new GridLayout(2,3,2,2));
this.add(new Label("字符"),Label.RIGHT);
text_char=new TextField("汉字",10);
this.add(text_char);
button_char=new Button("查询Unicode码");
this.add(button_char);
button_char.addActionListener(this);
this.add(new Label("Unicode编码",Label.RIGHT));
text_uni=new TextField(10);
this.add(text_uni);
button_uni=new Button("查询字符");
this.add(button_uni);
button_uni.addActionListener(this);
this.addWindowListener(new WinClose());
this.setVisible(true);
}
public void actionPerformd(ActionEvent ev)
{
if(ev.getSource()==button_char)
{ String str=text_char.getText();
if(str.equals(""))
return;
char ch=str.charAt(0);
text_char.setText(""+ch);
text_uni.setText(""+(int)ch);
}
else if(ev.getSource()==button_uni)
{ String str=text_uni.getText();
if(str.equals(""))
return;
int uni=Integer.parseInt(str);
text_char.setText(""+(char)uni);
}
}
public static void main(String arg[]) { new QueryFrame(); }
}
下面是窗口的监听,没有问题,字数限制就不粘了。
求大神解答。
这是下面的
class WinClose implements WindowListener
{
public void windowClosing(WindowEvent ev)
{ System.exit(0);
}
public void windowOpened(WindowEvent ev) {}
public void windowActivated(WindowEvent ev) {}
public void windowDeactivated(WindowEvent ev) {}
public void windowClosed(WindowEvent ev) {}
public void windowIconified(WindowEvent ev) {}
public void windowDeiconified(WindowEvent ev) {}
}
大神可以在MyEclipse里看看。。。 展开
The type QueryFrame must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent),新手求指导。
import java.awt.*;
import java.awt.event.*;
public class QueryFrame extends Frame implements ActionListener
{
private TextField text_char,text_uni;
private Button button_char,button_uni;
public QueryFrame()
{
super("Unicode字符查询器");
this.setBounds(300, 240, 280, 90);
this.setBackground(Color.lightGray);
this.setLayout(new GridLayout(2,3,2,2));
this.add(new Label("字符"),Label.RIGHT);
text_char=new TextField("汉字",10);
this.add(text_char);
button_char=new Button("查询Unicode码");
this.add(button_char);
button_char.addActionListener(this);
this.add(new Label("Unicode编码",Label.RIGHT));
text_uni=new TextField(10);
this.add(text_uni);
button_uni=new Button("查询字符");
this.add(button_uni);
button_uni.addActionListener(this);
this.addWindowListener(new WinClose());
this.setVisible(true);
}
public void actionPerformd(ActionEvent ev)
{
if(ev.getSource()==button_char)
{ String str=text_char.getText();
if(str.equals(""))
return;
char ch=str.charAt(0);
text_char.setText(""+ch);
text_uni.setText(""+(int)ch);
}
else if(ev.getSource()==button_uni)
{ String str=text_uni.getText();
if(str.equals(""))
return;
int uni=Integer.parseInt(str);
text_char.setText(""+(char)uni);
}
}
public static void main(String arg[]) { new QueryFrame(); }
}
下面是窗口的监听,没有问题,字数限制就不粘了。
求大神解答。
这是下面的
class WinClose implements WindowListener
{
public void windowClosing(WindowEvent ev)
{ System.exit(0);
}
public void windowOpened(WindowEvent ev) {}
public void windowActivated(WindowEvent ev) {}
public void windowDeactivated(WindowEvent ev) {}
public void windowClosed(WindowEvent ev) {}
public void windowIconified(WindowEvent ev) {}
public void windowDeiconified(WindowEvent ev) {}
}
大神可以在MyEclipse里看看。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询