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)*/
答案 0 :(得分:2)
frame.addWindowListener(new Object(type)
使用this
代替new Object()
,因为addWindowListener
需要WindowListener
参数,而this
则代表WindowListene
已实施的类
frame.addWindowListener(this);
此外,您在代码中没有引用ActionListener actionPerformed
,而您需要。即使您向任何组件注册ActionListener
也是如此。你没有向我们展示一些东西。
此外,我完全不知道class _anm1 {}
正在尝试做什么。摆脱它并按照上面的指示传递this
。
您还必须删除方法签名中的static
,因为方法(this)中引用的类不是static
。如果你的课程中有一堆不必要的static
字段和static
方法,那么你就会遇到问题,而且你面前有一个很大的重构(取决于它有多糟糕)。
在difference between instance field and static field in Java上进行Google搜索并阅读一些结果。
任何其他问题,我们必须看到更多代码。