我在一个名为 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、两个标签和另一个面板,我需要将它们排列在 Frame 中?我只需要知道如何创建和使用 GridLayout 对象。谢谢。
窗口应该是这样的:
________________________________________________________________________________
|Play - 0 x |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Score List: |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Mario: 100 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Luigi: 50 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Waluigi: 20 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Wario: 10 |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|Status: Ready! Score: 30 |
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
百分比符号只是游戏发生的屏幕。我希望这有帮助。