Skip to content
Snippets Groups Projects
Commit 878ee37d authored by steyer's avatar steyer
Browse files

manualtest törölve + Main

parent 8d99eacf
No related branches found
No related tags found
No related merge requests found
package game;
import java.awt.BorderLayout;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
public class JTableTest {
public static void main(String[] args) {
GameModel testModel = new GameModel(10, 10);
testModel.setValueAt(true, 4, 4);
testModel.setValueAt(true, 4, 5);
testModel.setValueAt(true, 4, 6);
testModel.setValueAt(true, 5, 3);
testModel.setValueAt(true, 5, 4);
testModel.setValueAt(true, 5, 5 );
JFrame testFrame = new JFrame();
testFrame.setLayout(new BorderLayout());
testFrame.add(new JTable(testModel));
testFrame.setSize(300, 300);
JButton stepButton = new JButton("Step");
JButton startButton = new JButton("Start");
JButton stopButton = new JButton("Stop");
startButton.addActionListener(new StartButtonListener(testModel));
stepButton.addActionListener(new StepButtonListener(testModel));
stopButton.addActionListener(new StopButtonListener(testModel));
JPanel bottomPanel = new JPanel();
bottomPanel.add(stepButton);
bottomPanel.add(startButton);
bottomPanel.add(stopButton);
testFrame.add(bottomPanel, BorderLayout.PAGE_END);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
testFrame.setVisible(true);
}
}
package game;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class StartButtonListener implements ActionListener {
private GameModel model;
public StartButtonListener(GameModel model) {
this.model=model;
}
@Override
public void actionPerformed(ActionEvent e) {
model.start();
}
}
package game;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class StepButtonListener implements ActionListener {
private GameModel model;
public StepButtonListener(GameModel model) {
this.model=model;
}
public void actionPerformed(ActionEvent e) {
model.step();
}
}
package game;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class StopButtonListener implements ActionListener {
private GameModel model;
public StopButtonListener(GameModel model) {
this.model = model;
}
public void actionPerformed(ActionEvent e) {
model.stop();
}
}
package game;
import game.StartWindow;
import javax.swing.JFrame;
public class StartWindowTest {
public class Main {
public static void main(String[] args) {
JFrame startWindowFrame = new StartWindow(new StartModel());
startWindowFrame.setVisible(true);
StartModel start = new StartModel();
//start.loadFromFile();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment