Sfoglia il codice sorgente

New Button Design :)

tolatesry 7 anni fa
parent
commit
aae15d5b53
1 ha cambiato i file con 32 aggiunte e 3 eliminazioni
  1. 32 3
      src/ui/view/GUI.java

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

@@ -192,6 +192,12 @@ public class GUI implements CategoryListener {
 	private final JComboBox comboBox = new JComboBox();
 	// Buttons
 	private final JButton btnAdd = new JButton("New");
+	private final JPopupMenu btnAddPopUp = new JPopupMenu("New");
+	private final JMenuItem mItemNew = new JMenuItem("New..");
+	private final JMenuItem mItemCategory = new JMenuItem("Category");
+	private final JMenuItem mItemObject = new JMenuItem("Object");
+	private final JMenuItem mItemSwitch = new JMenuItem("Switch");
+	private final JMenuItem mItemBattery = new JMenuItem("Battery");
 	private final JButton btnDel = new JButton("Delete");
 	private final JButton btnAddHolEL = new JButton("New");
 	private final JButton btnDelHolEL = new JButton("Delete");
@@ -1951,8 +1957,31 @@ public class GUI implements CategoryListener {
 		//toolBar.add(comboBox);
 		//comboBox.setModel(new DefaultComboBoxModel(comboBoxCat));
 		// Add Buttonnew DefaultComboBoxModel(comboBoxCat)
+		btnAddPopUp.add(mItemNew);
+		mItemNew.addActionListener(actionEvent -> {
+			System.out.println("New..");
+		});
+		btnAddPopUp.addSeparator();
+		btnAddPopUp.add(mItemCategory);
+		mItemCategory.addActionListener(actionEvent -> {
+			System.out.println("Category");
+		});
+		btnAddPopUp.add(mItemObject);
+		mItemObject.addActionListener(actionEvent -> {
+			System.out.println("Object");
+		});
+		btnAddPopUp.add(mItemSwitch);
+		mItemSwitch.addActionListener(actionEvent -> {
+			System.out.println("Switch");
+		});
+		btnAddPopUp.add(mItemBattery);
+		mItemBattery.addActionListener(actionEvent -> {
+			System.out.println("Battery");
+		});
 		btnAdd.addActionListener(actionEvent -> {
-			JOptionPane.showMessageDialog(contentPane, "Work in Progress" , "Message" , JOptionPane.WARNING_MESSAGE);
+			btnAddPopUp.show(btnAdd, 0, 0);
+			//btnAddPopUp.
+			//JOptionPane.showMessageDialog(contentPane, "Work in Progress" , "Message" , JOptionPane.WARNING_MESSAGE);
 			/*
 			Object nodeInfo = tree.getLastSelectedPathComponent();
 			String selectedOption = comboBox.getSelectedItem().toString();
@@ -1993,7 +2022,7 @@ public class GUI implements CategoryListener {
 			tree.repaint();
 			*/
 		});
-		
+		toolBar.add(btnAdd);
 		/**
 		 * Help Menu Action Listeners
 		 */
@@ -2127,7 +2156,7 @@ public class GUI implements CategoryListener {
 			}
 		});
 
-		toolBar.add(btnAdd);
+		
 
 		// Del Button
 		btnDel.addActionListener(actionEvent -> {