1 周
Questions & Answers
2377
package in.ac.iitb.cfilt.hwnbrowser;
import java.awt.BorderLayout;
import java.awt.event.*;
import javax.swing.*;
public class WordListBox extends JPanel
implements ActionListener, WindowListener
{
public static void showList(String type, String list[], String labelText, String title)
{
frame = new JFrame(title);
frame.setDefaultCloseOperation(2);
JComponent newContentPane = new WordListBox(type, list, labelText);
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
frame.addWindowListener(new Object(type)
class _anm1 {}
);
frame.pack();
frame.setVisible(true);
}
public void windowOpened(WindowEvent windowevent)
{
}
public void windowClosing(WindowEvent windowevent)
{
}
public void windowIconified(WindowEvent windowevent)
{
}
public void windowDeiconified(WindowEvent windowevent)
{
}
public void windowActivated(WindowEvent windowevent)
{
}
public void windowDeactivated(WindowEvent windowevent)
{
}
public void windowClosed(WindowEvent windowevent)
{
}
}
/*
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ";" to complete Statement
Syntax error, insert ")" to complete MethodInvocation
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ";" to complete Statement
Syntax error, insert ")" to complete MethodInvocation
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ";" to complete Statement
Syntax error, insert ")" to complete MethodInvocation
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ";" to complete Statement
Syntax error, insert ")" to complete MethodInvocation
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ";" to complete Statement
Syntax error, insert ")" to complete MethodInvocation
Syntax error on token ")", delete this token
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Object)
Syntax error, insert ";" to complete Statement
Syntax error, insert ")" to complete MethodInvocation
Syntax error on token ")", delete this token
at in.ac.iitb.cfilt.hwnbrowser.WNBrowserMain.createMenuBar(WNBrowserMain.java:43)
at in.ac.iitb.cfilt.hwnbrowser.WNBrowserMain.createAndShowGUI(WNBrowserMain.java:571)
at in.ac.iitb.cfilt.hwnbrowser.WNBrowserMain.main(WNBrowserMain.java:928)*/
# 1 楼答案
使用
this
而不是new Object()
,因为addWindowListener
需要一个WindowListener
参数,并且this
引用WindowListene
实现的类另外,在代码中没有对
ActionListener actionPerformed
的引用,这是需要的。甚至您将ActionListener
注册到任何组件。你没给我们看什么而且我完全不知道这个
class _anm1 {}
想做什么。摆脱它,只需像上面指出的那样通过this
您还必须去掉方法签名中的
static
,因为方法(this)中引用的类不是static
。如果您的类中有一堆不必要的static
字段和static
方法,那么您就有问题了,前面还有一个大的重构(取决于它有多糟糕)在difference between instance field and static field in Java上进行谷歌搜索,并阅读出现的一些结果
任何其他问题,我们将不得不看到更多的代码