JAVA GUI新手求助 下面这段代码为什么不能运行,RUN AS没有JAVA Application

请无视这稀烂的导包。。没有分了,前辈们帮忙看下吧。。。

package action;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.KeyStroke;

public class ActionFrame extends JFrame{
public static void mian(String[]args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
JFrame frame=new ActionFrame();
frame.setTitle("ActionFrame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
private JPanel buttonPanel;
public ActionFrame()
{
//JPanel buttonPanel=new JPanel();
setSize(400,300);
//buttonPanel=new JPanel();
Action redAction=new ColorAction("red",Color.red);
buttonPanel.add(new JButton(redAction));
add(buttonPanel);
InputMap imap=buttonPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
imap.put(KeyStroke.getKeyStroke("Crtl r"),"r");
ActionMap amap=buttonPanel.getActionMap();
amap.put("r",redAction);
}

private class ColorAction extends AbstractAction
{
public ColorAction(String name,Color c)
{
putValue(Action.NAME,name);
putValue("color",c);
}
public void actionPerformed(ActionEvent event)
{
Color x=(Color)getValue("color");
buttonPanel.setBackground(x);
//buttonPanel.setBackground(new Color((int) getValue("color")));
}
}
}

在public static void mian(String[]args)中写错了,应该是main
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答