Project

General

Profile

Revision 67

Added by Greg Tress over 16 years ago

updated gui code for cleanliness

View differences:

Colonet.java
46 46
	JPanel panelRobotDirection;
47 47
	JPanel panelRobotCommands;
48 48
	JButton btnF, btnB, btnL, btnR, btnActivate;
49
	JComboBox cmbRobotNum;
49 50
	
50 51
	// Task Manager
51 52
	JPanel panelTaskManager;
......
68 69
	
69 70
	Socket socket;					
70 71
	OutputStreamWriter out;			//TODO: add a BufferedWriter
71
	DataListener datalistener;  
72
	DataUpdater dataupdater;  
72 73
	
73 74
	Font botFont;
74 75
	Random random = new Random();
......
182 183
		// Robot Control and Commands
183 184
		panelRobotCommands = new JPanel();
184 185
		panelRobotCommands.setLayout(new FlowLayout());
186
		cmbRobotNum = new JComboBox();
187
		panelRobotCommands.add(cmbRobotNum);
185 188
		panelRobotCommands.add(new JLabel("Commands go here"));
186 189
		panelRobotControl = new JPanel();
187 190
		panelRobotControl.setLayout(new GridLayout(2,1));
......
277 280
		indicator = new SelectionIndicator(canvas);
278 281
		indicator.setRadius(RADIUS+3, 15);  //a tad more than the bot radius
279 282
		packetMonitor = new PacketMonitor();
280
		datalistener = new DataListener();
283
		dataupdater = new DataUpdater();
281 284
		
282 285
		csi = new ColonetServerInterface(log);
283 286
	
......
745 748
	}
746 749
	
747 750
	/*
748
	*	DataListener thread.
751
	*	DataUpdater thread.
749 752
	*
750 753
	*/
751
	class DataListener extends Thread {
752
		final int DATALISTENER_DELAY = 666;
753
		BufferedReader reader;
754
	class DataUpdater extends Thread {
755
		final int DATAUPDATER_DELAY = 666;
754 756
		
755
		public DataListener () {
756
			super("Colonet DataListener");
757
		public DataUpdater () {
758
			super("Colonet DataUpdater");
757 759
		}
758 760
		
759 761
		public void run () {
......
763 765
					if (csi == null) return;
764 766
					line = csi.getLine();
765 767
					if (line != null) {
766
						csi.msg("Incoming data: [" + line + "]");
768
						log.append("Incoming data: [" + line + "]");
767 769
						//TODO: parse incoming data here
770
						
771
						//request more data
772
						//csi.sendRequest("Get all data", "server");
773
						
774
						// update robot list
775
						int numRobots = 5;
776
						String [] robotList = new String[numRobots+1];
777
						robotList[0] = "All";
778
						for (int i = 1; i <= numRobots; i++)
779
							robotList[i] = "Robot " + i;
780
						cmbRobotNum = new JComboBox(robotList);
768 781
					}
769
					Thread.sleep(DATALISTENER_DELAY);
782
					Thread.sleep(DATAUPDATER_DELAY);
770 783
				} catch (InterruptedException e) {
771 784
					return;
772 785
				} 

Also available in: Unified diff