gpt4 book ai didi

java - 如何在Java中使用GridLayout?

转载 作者:行者123 更新时间:2023-12-01 04:13:10 25 4
gpt4 key购买 nike

我在一个名为 PlayFrame 的类中有这段代码:

public void construct(FieldPanel fPanel){
this.setTitle("Play");
Dimension dimension = new Dimension(1200,600);
this.setSize(dimension);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.pack();
GridLayout gLayout = new GridLayout();
this.setLayout(layout);
score.setText("Score: " + pField.scoreValue);
// this.add(score);
// this.add(scoreList);
// this.add(status);

如您所见,我尝试创建一个新的 GridLayout 对象,但我不确定如何使用它来显示必要的组件。我需要一个布局,其中左上角有一个大面板,右上角有一个分数列表面板,左下角有一个小状态标签,右下角有一个小分数标签。所以,我注释掉了一些东西,因为我不确定它们是否有效或者它们到底做了什么。如何让 PlayFrame 显示 fPanel、两个标签和另一个面板,按照我需要的方式将它们排列在框架中?我只需要知道如何创建和使用 GridLayout 对象。谢谢。

这就是窗口应该像的样子:

________________________________________________________________________________
|Play - 0 x |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Score List: |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Mario: 100 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Luigi: 50 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Waluigi: 20 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Wario: 10 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|Status: Ready! Score: 30 |
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

百分号只是游戏发生的屏幕。我希望这会有所帮助。

最佳答案

如果使用 eclipse 我发现 Window Builder对于创建 GUI 非常有用。否则,正如其他人所说,Oracle 网站是一个很好的起点。

关于java - 如何在Java中使用GridLayout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19699754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com