View Javadoc

1   package nl.tudelft.goal.visualizer.gui.panels;
2   
3   import java.awt.FlowLayout;
4   import javax.swing.BorderFactory;
5   import javax.swing.JButton;
6   import javax.swing.JLabel;
7   import javax.swing.JPanel;
8   import javax.swing.JSpinner;
9   import javax.swing.SpinnerNumberModel;
10  import javax.swing.border.TitledBorder;
11  
12  import nl.tudelft.goal.ut2004.visualizer.gui.action.ChangeMapAction;
13  import nl.tudelft.goal.ut2004.visualizer.gui.action.PauseResumeAction;
14  import nl.tudelft.goal.ut2004.visualizer.gui.action.SetSpeedAction;
15  import nl.tudelft.goal.ut2004.visualizer.gui.widgets.MapBox;
16  
17  public class ServerPanel extends JPanel {
18  
19  	private final JButton pause;
20  	private final JSpinner speedSelection;
21  	private final JLabel setSpeed;
22  	private final MapBox mapSelection;
23  	private final JButton changeMap;
24  
25  	public ServerPanel() {
26  
27  		// Add buttons
28  		this.pause = new JButton(new PauseResumeAction());
29  		this.speedSelection = new JSpinner(
30  		// 1 = default speed, 0.1 minimum, 5.0 max. 0.1 step size.
31  				new SpinnerNumberModel(1, 0.1, 5.0, 0.1));
32  		this.speedSelection
33  				.setEditor(new JSpinner.NumberEditor(speedSelection));
34  		this.setSpeed = new JLabel("GameSpeed");
35  
36  		this.mapSelection = new MapBox();
37  		this.changeMap = new JButton("Change map");
38  		this.changeMap.addActionListener(new ChangeMapAction(mapSelection));
39  
40  		// Add listeners to buttons
41  		speedSelection.addChangeListener(new SetSpeedAction(speedSelection));
42  		//getAct().act(new AddBot(botName, location, rotation, skill, type));
43  
44  		// Add buttons to frame.
45  		setLayout(new FlowLayout(FlowLayout.LEFT));
46  		add(pause);
47  		add(setSpeed);
48  		add(speedSelection);
49  		add(mapSelection);
50  		add(changeMap);
51  
52  		// Handle frame looks
53  		TitledBorder title = BorderFactory
54  				.createTitledBorder("Server Controls");
55  		setBorder(title);
56  
57  	}
58  }