|
@@ -13,6 +13,7 @@ import java.awt.event.ActionListener;
|
|
|
import javax.swing.BorderFactory;
|
|
import javax.swing.BorderFactory;
|
|
|
import javax.swing.BoxLayout;
|
|
import javax.swing.BoxLayout;
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JButton;
|
|
|
|
|
+import javax.swing.JComboBox;
|
|
|
import javax.swing.JDialog;
|
|
import javax.swing.JDialog;
|
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JOptionPane;
|
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
@@ -22,10 +23,14 @@ public class SimulatorDialogPane extends JDialog{
|
|
|
|
|
|
|
|
private JTextField length;
|
|
private JTextField length;
|
|
|
private JTextField width;
|
|
private JTextField width;
|
|
|
|
|
+ private JComboBox<String> terrain;
|
|
|
private MainFrame mainFrame;
|
|
private MainFrame mainFrame;
|
|
|
|
|
+ private int terrainInt;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public SimulatorDialogPane(MainFrame mainFrame){
|
|
public SimulatorDialogPane(MainFrame mainFrame){
|
|
|
this.mainFrame = mainFrame;
|
|
this.mainFrame = mainFrame;
|
|
|
|
|
+ this.terrainInt = 1;
|
|
|
this.getContentPane().setBackground( Color.WHITE );
|
|
this.getContentPane().setBackground( Color.WHITE );
|
|
|
JPanel main = new JPanel();
|
|
JPanel main = new JPanel();
|
|
|
main.setOpaque(false);
|
|
main.setOpaque(false);
|
|
@@ -36,6 +41,7 @@ public class SimulatorDialogPane extends JDialog{
|
|
|
main.add(label);
|
|
main.add(label);
|
|
|
main.add(this.widthPanel());
|
|
main.add(this.widthPanel());
|
|
|
main.add(this.lengthPanel());
|
|
main.add(this.lengthPanel());
|
|
|
|
|
+ main.add(this.terrainChoosePanel());
|
|
|
main.add(this.buttons());
|
|
main.add(this.buttons());
|
|
|
main.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
|
main.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
|
|
|
|
|
|
@@ -76,6 +82,39 @@ public class SimulatorDialogPane extends JDialog{
|
|
|
name.add(this.width);
|
|
name.add(this.width);
|
|
|
return name;
|
|
return name;
|
|
|
}
|
|
}
|
|
|
|
|
+ private JPanel terrainChoosePanel(){
|
|
|
|
|
+ JPanel name = new JPanel();
|
|
|
|
|
+ name.setOpaque(false);
|
|
|
|
|
+ name.setLayout(new BoxLayout(name, BoxLayout.X_AXIS));
|
|
|
|
|
+ name.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
|
|
|
|
|
+ Label label = new Label("Terrain");
|
|
|
|
|
+ label.setBackground(Color.WHITE);
|
|
|
|
|
+ label.setFont(new Font("Arial", Font.PLAIN, 11));
|
|
|
|
|
+ name.add(label);
|
|
|
|
|
+ String[] terrainStrings = { "Beach", "Grass", "Urban"};
|
|
|
|
|
+ this.terrain = new JComboBox<String>(terrainStrings);
|
|
|
|
|
+ this.terrain.setSelectedIndex(1);
|
|
|
|
|
+ this.terrain.addActionListener(new ActionListener(){
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ JComboBox<String> cb = (JComboBox<String>)e.getSource();
|
|
|
|
|
+ String terrainName = (String)cb.getSelectedItem();
|
|
|
|
|
+ switch(terrainName){
|
|
|
|
|
+ case "Beach": setTerrainInt(1);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "Grass": setTerrainInt(2);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "Urban": setTerrainInt(3);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }});
|
|
|
|
|
+ name.add(this.terrain);
|
|
|
|
|
+ return name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void setTerrainInt(int number){
|
|
|
|
|
+ this.terrainInt = number;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private JPanel buttons(){
|
|
private JPanel buttons(){
|
|
|
JPanel buttons = new JPanel();
|
|
JPanel buttons = new JPanel();
|
|
@@ -109,6 +148,7 @@ public class SimulatorDialogPane extends JDialog{
|
|
|
int width = Integer.parseInt(this.width.getText());
|
|
int width = Integer.parseInt(this.width.getText());
|
|
|
this.mainFrame.setLength(length);
|
|
this.mainFrame.setLength(length);
|
|
|
this.mainFrame.setWidth(width);
|
|
this.mainFrame.setWidth(width);
|
|
|
|
|
+ this.mainFrame.setTerrain(terrainInt);
|
|
|
this.mainFrame.changeView(MainFrame.Views.SIMULATOR);
|
|
this.mainFrame.changeView(MainFrame.Views.SIMULATOR);
|
|
|
dispose();
|
|
dispose();
|
|
|
}
|
|
}
|