package game;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.GraphicsConfiguration;
import java.awt.PopupMenu;
import java.awt.event.ComponentListener;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.plaf.metal.MetalBorders.PopupMenuBorder;
public class START extends JFrame {
/**
* author:null
*
*/
private static final long serialVersionUID = 1L;
@SuppressWarnings("null")
public static void main(String[] args) throws InterruptedException, IOException {String title = null;
{
JFrame start = new JFrame(title);
Container s1 = start.getContentPane();
JLabel s2 = new JLabel("----------猜字游戏----------");
JLabel s3 = new JLabel("欢迎游玩此游戏!!!");
JLabel s4 = new JLabel("规则与注意事项:");
JLabel s5 = new JLabel("1.请勿强行终止此程序!");
JLabel s6 = new JLabel("2.填写用户名和数字时请勿为空!!!");
JLabel s7 = new JLabel("====================");
JLabel s8 = new JLabel("10S后自动开始游戏!!!");
Component container = null;
s2.setHorizontalAlignment(SwingConstants.CENTER);
s3.setHorizontalAlignment(SwingConstants.CENTER);
s4.setHorizontalAlignment(SwingConstants.CENTER);
s5.setHorizontalAlignment(SwingConstants.CENTER);
s6.setHorizontalAlignment(SwingConstants.CENTER);
s7.setHorizontalAlignment(SwingConstants.CENTER);
s8.setHorizontalAlignment(SwingConstants.CENTER);
container.add(s2);为什么一直在“container.add(s2);”上面提示:类型 Component 中的方法 add(PopupMenu)对于参数(JLabel)不适用??有什么办法解决???
3 回答
MineDearm
TA贡献1条经验 获得超1个赞
把Container s1 = start.getContentPane();改成
Container container = start.getContentPane();就行了。
添加回答
举报
0/150
提交
取消