小编Dan*_*iel的帖子

为什么不显示GUI

这段代码有什么问题?GUI未显示.这是我实验室项目的4x4图片内存的GUI.任何帮助,将不胜感激 .

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class memory extends JFrame implements ActionListener {

    String pictures[]
            = {"riven1.jpg", "riven2.jpg", "riven3.jpg", "riven4.jpg", "riven5.jpg", "riven6.jpg", "riven7.jpg", "riven8.jpg"};

    JButton button[];

    public memory() {
        Container c = getContentPane();
        setTitle("Memory Game");
        panel.setLayout(new GridLayout(4, 4));
        for (int x = 0; x < 16; x++) {
            button[x] = new JButton(new ImageIcon(pictures[x]));
            c.add(button[x]);
            button[x].addActionListener(this);
        }
        setSize(700, 700);
        setVisible(true);
        setLocationRelativeTo(null);
    }

    public void actionPerformed(ActionEvent e) {

    }

    public static void main(String args[]) {
        new memory();
    }
}
Run Code Online (Sandbox Code Playgroud)

java user-interface swing

-8
推荐指数
1
解决办法
144
查看次数

标签 统计

java ×1

swing ×1

user-interface ×1