Skip to content

Commit

Permalink
updated layout
Browse files Browse the repository at this point in the history
  • Loading branch information
terfloth committed Nov 13, 2018
1 parent 2b82ddc commit 3447ac1
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions examples/RocketLanding/src/com/edu4java/samplegame/Game.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.edu4java.samplegame;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand All @@ -12,8 +14,8 @@
import javax.swing.JPanel;

import org.yakindu.scr.TimerService;
import org.yakindu.scr.rocketlanding2.IRocketLanding2Statemachine.SCIGameListener;
import org.yakindu.scr.rocketlanding2.SynchronizedRocketLanding2Statemachine;
import org.yakindu.scr.rocketlanding.IRocketLandingStatemachine.SCIGameListener;
import org.yakindu.scr.rocketlanding.SynchronizedRocketLandingStatemachine;

@SuppressWarnings("serial")

Expand All @@ -22,7 +24,7 @@ public class Game extends JPanel implements KeyListener, ActionListener {
public static final int FRAME_WIDTH = 300;
public static final int FRAME_HEIGHT = 400;

private SynchronizedRocketLanding2Statemachine sm;
private SynchronizedRocketLandingStatemachine sm;

private JButton buttonPauseUnpause;
private JButton buttonLeft;
Expand All @@ -40,6 +42,13 @@ public Game(){
setFocusable(true);
setFocusTraversalKeysEnabled(false);


JPanel pane = new JPanel();
pane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;


setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
// setLayout(null);

Expand All @@ -55,7 +64,7 @@ public void actionPerformed(ActionEvent e) {
sm.getSCIGame().raiseAutopilotPressed();
}
});

this.buttonHumanPilot = new JButton("Manual Control");
this.buttonHumanPilot.setPreferredSize(smallButtonDimension);
this.buttonHumanPilot.addActionListener( new ActionListener() {
Expand Down Expand Up @@ -99,14 +108,32 @@ public void actionPerformed(ActionEvent e) {
this.scene.setMaximumSize(this.scene.getPreferredSize());

this.add(this.scene);
this.add(pane);

c.gridx = 0;
c.gridy = 0;
pane.add(this.buttonAutoPilot, c);

c.gridx = 1;
c.gridy = 0;
pane.add(this.buttonHumanPilot, c);

c.gridx = 0;
c.gridy = 1;
c.gridwidth = 2;
pane.add(this.buttonPauseUnpause, c);

c.gridx = 0;
c.gridy = 2;
c.gridwidth = 1;
pane.add(this.buttonLeft, c);

c.gridx = 1;
c.gridy = 2;
pane.add(this.buttonRight, c);

this.add(this.buttonAutoPilot);
this.add(this.buttonHumanPilot);
this.add(this.buttonPauseUnpause);
this.add(this.buttonLeft);
this.add(this.buttonRight);

this.sm = new SynchronizedRocketLanding2Statemachine();
this.sm = new SynchronizedRocketLandingStatemachine();
sm.setTimer(new TimerService());
sm.init();

Expand Down

0 comments on commit 3447ac1

Please sign in to comment.