开发者社区> 问答> 正文

调用类中的JFrame

我正在用Java swing制作2D游戏。我试着进行方形移动,但没有加载任何内容,因为我不记得方形Java上的类了。

public class tile {
    tile(int widthScreen, int heightScreen) throws IOException {

        JFrame tileframe = new JFrame("tileframe");
        tileframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

        FirstLevel connect = new FirstLevel(widthScreen, heightScreen, tileframe);
public FirstLevel(int widthScreen, int heightScreen, JFrame tileframe)   // Constructor is passed the size of the parent frame
    {
//        // Start the timer
//        shapeTimer.start();

        addKeyListener(this);
        setFocusable(true);
        setFocusTraversalKeysEnabled(false);

        xBound = (windowWidth - squareSize);
        yBound = (windowHeight - squareSize);
    }

我运行游戏,但无法正常工作。JFrame不会被召回

展开
收起
垚tutu 2019-11-28 18:46:17 619 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载