JPanel p4 = new JPanel(); JPanel p4c = new JPanel(); p4c.setLayout(new GridLayout(1, 3, 5, 5));
JButton b4 = new JButton("Search"); b4.addActionListener(this); p4c.add(b4);
p4.add(p4c); 下面就是对应的actionPerformed函数了。错误提示: TextDemo.java:66:addActionListener<java.awt.event.ActionListener> in javax.swing.AbstractButton cannon be applied to <TextDemo> b4.addActionListener<this>; ^ 1 error
main class <TextDemo> 应该 implements ActionListener.
还是看看代码吧,可能你漏了些东东。
JPanel p4c = new JPanel(); p4c.setLayout(new GridLayout(1, 3, 5, 5));
JButton b4 = new JButton("Search");
b4.addActionListener(this);
p4c.add(b4);
p4.add(p4c);
下面就是对应的actionPerformed函数了。错误提示:
TextDemo.java:66:addActionListener<java.awt.event.ActionListener> in javax.swing.AbstractButton cannon be applied to <TextDemo>
b4.addActionListener<this>;
^
1 error