Java窗口实例无法运行的问题

来源:百度知道 编辑:UC知道 时间:2024/06/17 07:28:07
代码如下:(编译提示我ButtonTest.java 使用或覆盖了已过时的API,并且让我用-Xlint:deprecation 重新编译...什么问题啊?是需要建个.htm文件在里面运行吗?我试过了,不行的说!求方法,代码应该没问题!)

package myevent;
import java.awt.*;
import java.awt.event.*;

class ButtonPanel extends Panel //implements ActionListener
{
public ButtonPanel()
{
yellowButton = new Button("Yellow");
blueButton = new Button("Blue");
redButton = new Button("Red");

add(yellowButton);
add(blueButton);
add(redButton);

MyListenerAction bAction = new MyListenerAction(Color.blue);
MyListenerAction gAction = new MyListenerAction(Color.green);
MyListenerAction eAction = new MyListenerAction(Color.red);
yellowButton.addActionListener(bAction);
blueButton.addActionListener(gAction);
redButton.addActionListener(eAction);
}

// public void actionPe

用或覆盖了已过时的API,并且让我用-Xlint:deprecation 重新编译.
这个问题是不影响最后的结果的,是你使用了比你JDK版本落后的方法!
只有APPLE需要htm,application应用程序不需要html的!

要显示,最后至少加一行代码,frame.visible=true;

可以运行啊,检查一下你的包名正确吗