Sfoglia il codice sorgente

GUI Category Panels and Button

Teh-Hai Julian Zheng 8 anni fa
parent
commit
e427374d45
7 ha cambiato i file con 33 aggiunte e 35 eliminazioni
  1. 1 0
      .classpath
  2. 0 31
      Model.java
  3. 0 1
      bin/.gitignore
  4. BIN
      bin/ui/view/GUI$1.class
  5. BIN
      bin/ui/view/GUI$2.class
  6. BIN
      bin/ui/view/GUI.class
  7. 32 3
      src/ui/view/GUI.java

+ 1 - 0
.classpath

@@ -2,5 +2,6 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

+ 0 - 31
Model.java

@@ -1,31 +0,0 @@
-package ui.model;
-
-import java.util.ArrayList;
-
-import ui.controller.*;
-
-public class Model {
-	private ArrayList<Category> Categories;
-	private ArrayList<HolonObject> ObjectsOnCanvas;
-	
-	public Model(){
-		Categories = new ArrayList<Category>();
-		ObjectsOnCanvas = new ArrayList<HolonObject>();
-	}
-	
-	public void addCategory(Category toAdd){
-		Categories.add(toAdd);
-	}
-	
-	public void deleteCategory(int idx){
-		Categories.remove(idx);
-	}
-	
-	public void addObject(HolonObject toAdd){
-		ObjectsOnCanvas.add(toAdd);
-	}
-	
-	public void deleteObject(int idx){
-		ObjectsOnCanvas.remove(idx);
-	}
-}

+ 0 - 1
bin/.gitignore

@@ -1,2 +1 @@
 /ui/
-/tests/

BIN
bin/ui/view/GUI$1.class


BIN
bin/ui/view/GUI$2.class


BIN
bin/ui/view/GUI.class


+ 32 - 3
src/ui/view/GUI.java

@@ -31,6 +31,20 @@ import java.awt.Window.Type;
 import javax.swing.JInternalFrame;
 import java.awt.BorderLayout;
 import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.JToolBar;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.ListSelectionModel;
+import javax.swing.AbstractListModel;
+import java.awt.Choice;
+import javax.swing.JComboBox;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Font;
 
 public class GUI {
 
@@ -58,6 +72,11 @@ public class GUI {
 	private JTable table;
 	private final JTable table_2 = new JTable();
 	private Model model;
+	private final JPanel panel = new JPanel();
+	private final JTextField textField = new JTextField();
+	private final JComboBox comboBox = new JComboBox();
+	private final JButton btnAdd = new JButton("Add");
+	private final JToolBar toolBar = new JToolBar();
 	
 
 	/**
@@ -73,6 +92,7 @@ public class GUI {
 	 */
 	@SuppressWarnings("serial")
 	private void initialize() {
+		textField.setColumns(10);
 		frmCyberPhysical = new JFrame();
 		frmCyberPhysical.setTitle("Cyber Physical Systems Model");
 		frmCyberPhysical.setBounds(100, 100, 891, 467);
@@ -95,9 +115,6 @@ public class GUI {
 		menuBar.add(mnNewMenu_3);
 		
 		menuBar.add(mnHelp);
-		frmCyberPhysical.getContentPane().setLayout(new BoxLayout(frmCyberPhysical.getContentPane(), BoxLayout.X_AXIS));
-		
-		frmCyberPhysical.getContentPane().add(splitPane);
 		
 		//Table
 		String[] columnNames = {"Consumer",
@@ -154,6 +171,7 @@ public class GUI {
 		table_2.getColumnModel().getColumn(0).setPreferredWidth(103);
 		table_2.getColumnModel().getColumn(1).setPreferredWidth(107);
 		table_2.getColumnModel().getColumn(2).setPreferredWidth(125);
+		frmCyberPhysical.getContentPane().setLayout(new BorderLayout(0, 0));
 		splitPane_2.setDividerLocation(200);
 		
 		splitPane.setLeftComponent(scrollPane_1);
@@ -162,6 +180,17 @@ public class GUI {
 		
 		scrollPane_1.setViewportView(tree);
 		
+		scrollPane_1.setColumnHeaderView(panel);
+		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+		toolBar.setFloatable(false);
+		
+		panel.add(toolBar);
+		toolBar.add(comboBox);
+		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Category", "Object"}));
+		toolBar.add(btnAdd);
+		panel.add(textField);
+		frmCyberPhysical.getContentPane().add(splitPane);
+		
 		mntmOpen.addActionListener(new java.awt.event.ActionListener() {
 	        @Override
 	        public void actionPerformed(java.awt.event.ActionEvent evt) {