import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
public class JFrame_8 extends javax.swing.JFrame { /** Creates new form JFrame_8 */
public JFrame_8() {
initComponents ();
pack ();
ActionListener listener = new TimePrinter();
Timer t = new Timer(1000,listener);
t.start();
}
private class TimerPrinter implements ActionListener
{
public TimerPrinter()
{
public void actionPerformed(ActionEvent event)
{
JFrame_8 frame = new JFrame_8();
frame.setBackground(Color.black);
System.out.println("hello");
}
}
}
public static void main (String args[]) {
new JFrame_8 ().show ();
}
为什么运行后会出现:
JFrame_8.java [50:1] class JFrame_8$TimerPrinter must be declared abstract. It does not define public abstract void actionPerformed(ActionEvent) from class java.awt.event.ActionListener
private class TimerPrinter implements ActionListener
^
1 error
我是个初学者,不太懂,望各位师父帮助一下!
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
public class JFrame_8 extends javax.swing.JFrame { /** Creates new form JFrame_8 */
public JFrame_8() {
initComponents ();
pack ();
ActionListener listener = new TimePrinter();
Timer t = new Timer(1000,listener);
t.start();
}
private class TimerPrinter implements ActionListener
{
public TimerPrinter()
{
public void actionPerformed(ActionEvent event)
{
JFrame_8 frame = new JFrame_8();
frame.setBackground(Color.black);
System.out.println("hello");
}
}
}
public static void main (String args[]) {
new JFrame_8 ().show ();
}
为什么运行后会出现:
JFrame_8.java [50:1] class JFrame_8$TimerPrinter must be declared abstract. It does not define public abstract void actionPerformed(ActionEvent) from class java.awt.event.ActionListener
private class TimerPrinter implements ActionListener
^
1 error
我是个初学者,不太懂,望各位师父帮助一下!
public TimerPrinter()
{ }
public void actionPerformed(ActionEvent event)
{
JFrame_8 frame = new JFrame_8();
frame.setBackground(Color.black);
System.out.println("hello");
}