/**
		 * Set up the applet's GUI.
		 * As recommended, the init method executes this in the event-dispatching 
		 * thread.
		 */
		public void run()
		{
			Container pane = getContentPane();
			pane.setLayout(new BorderLayout());

			// Build the button controls
			JRadioButton voronoiButton = new JRadioButton("Voronoi Diagram");
			voronoiButton.setActionCommand("voronoi");
			JRadioButton delaunayButton = new JRadioButton("Delaunay Triangulation");
			delaunayButton.setActionCommand("delaunay");
			JButton clearButton = new JButton("Clear");
			clearButton.setActionCommand("clear");
			
			ButtonGroup group = new ButtonGroup();
			group.add(voronoiButton);
			group.add(delaunayButton);
			JPanel buttonPanel = new JPanel();
			buttonPanel.add(voronoiButton);
			buttonPanel.add(delaunayButton);
			buttonPanel.add(clearButton);
			pane.add(buttonPanel, "North");

			// Build the mouse-entry switches
			JLabel circleLabel = new JLabel("Show Empty Circles");
			circleLabel.setName("circles");
			JLabel delaunayLabel = new JLabel("Show Delaunay Edges");
			delaunayLabel.setName("delaunay");
			JLabel voronoiLabel = new JLabel("Show Voronoi Edges");
			voronoiLabel.setName("voronoi");
			JPanel switchPanel = new JPanel();
			switchPanel.add(circleLabel);
			switchPanel.add(new Label("     "));
			switchPanel.add(delaunayLabel);
			switchPanel.add(new Label("     "));
			switchPanel.add(voronoiLabel);
			pane.add(switchPanel, "South");

			// Build the graphics panel
			DelaunayPanel graphicsPanel = new DelaunayPanel();
			graphicsPanel.setBackground(Color.gray);
			pane.add(graphicsPanel, "Center");

			// Register the listeners
			voronoiButton.addActionListener(graphicsPanel);
			delaunayButton.addActionListener(graphicsPanel);
			clearButton.addActionListener(graphicsPanel);
			graphicsPanel.addMouseListener(graphicsPanel);
			circleLabel.addMouseListener(graphicsPanel);
			delaunayLabel.addMouseListener(graphicsPanel);
			voronoiLabel.addMouseListener(graphicsPanel);

			// Initialize the radio buttons
			voronoiButton.doClick();
		}
Exemple #2
0
 private JComponent getLogComponent()
 {
     var jpanel = new JPanel(new BorderLayout());
     var jtextarea = new JTextArea();
     logger.addHandler(new GuiLogOutputHandler(jtextarea));
     var jscrollpane = new JScrollPane(jtextarea, 22, 30);
     jtextarea.setEditable(false);
     var jtextfield = new JTextField();
     jtextfield.addActionListener(new ServerGuiCommandListener(this, jtextfield));
     jtextarea.addFocusListener(new ServerGuiFocusAdapter(this));
     jpanel.add(jscrollpane, "Center");
     jpanel.add(jtextfield, "South");
     jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
     return jpanel;
 }
Exemple #3
0
 private JComponent getStatsComponent()
 {
     var jpanel = new JPanel(new BorderLayout());
     jpanel.add(new GuiStatsComponent(), "North");
     jpanel.add(getPlayerListComponent(), "Center");
     jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Stats"));
     return jpanel;
 }