作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在一个名为 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/
我是一名优秀的程序员,十分优秀!