用Eclipse编Java提示The method show() from the type Window is deprecated,并且窗口没有出现
importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassfirstclassimpl...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class firstclass implements ActionListener, WindowListener
{
public firstclass()
{
JFrame f = new JFrame("EventDemo1");
Container contentPane = f.getContentPane();
JButton b = new JButton("按我有声音喔");
b.addActionListener(this);
contentPane.add(b);
f.pack();
f.show();///////////////////////////////////The method show() from the type Window is deprecated
f.addWindowListener(this);
}
public static void main(String args[])
{
new firstclass();
}
public void actionPerformed(ActionEvent e)
{
Toolkit.getDefaultToolkit().beep();
}
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowClosing(WindowEvent e){}
{
System.exit(0);
}
} 展开
import java.awt.event.*;
import javax.swing.*;
public class firstclass implements ActionListener, WindowListener
{
public firstclass()
{
JFrame f = new JFrame("EventDemo1");
Container contentPane = f.getContentPane();
JButton b = new JButton("按我有声音喔");
b.addActionListener(this);
contentPane.add(b);
f.pack();
f.show();///////////////////////////////////The method show() from the type Window is deprecated
f.addWindowListener(this);
}
public static void main(String args[])
{
new firstclass();
}
public void actionPerformed(ActionEvent e)
{
Toolkit.getDefaultToolkit().beep();
}
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowClosing(WindowEvent e){}
{
System.exit(0);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询