changeset 72:3f25b75e6dac

TabSimpleSearch: Added a pupup menu for future options
author Fox
date Fri, 06 Jan 2023 23:49:28 +0100
parents dfedca84c36b
children d1faf5db459c
files src/junotu/TabSimpleSearch.java
diffstat 1 files changed, 26 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/junotu/TabSimpleSearch.java	Sat Dec 24 22:00:36 2022 +0100
+++ b/src/junotu/TabSimpleSearch.java	Fri Jan 06 23:49:28 2023 +0100
@@ -2,6 +2,7 @@
 
 import java.lang.RuntimeException;
 
+import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.event.InputEvent;
@@ -23,6 +24,8 @@
 import javax.swing.JTextField;
 import javax.swing.JScrollPane;
 import javax.swing.JScrollBar;
+import javax.swing.JPopupMenu;
+import javax.swing.JMenuItem;
 
 import junotu.Main;
 import junotu.Window.Tab;
@@ -38,8 +41,12 @@
     
     private JTextField field;
     private JButton create;
+    private JButton context;
+    private JPopupMenu menu;
     private Box results;
     private JScrollPane scroll;
+
+    private JMenuItem menu_calendar;
     
     public TabSimpleSearch()
     {
@@ -48,13 +55,19 @@
 	this.setLayout( new BorderLayout() );
 
 	JPanel top = new JPanel( new BorderLayout() );
+	Box buttonBox = Box.createHorizontalBox();
+	context = new JButton("=");
+	create = new JButton("+");
 	field = new JTextField();
-	create = new JButton("+");
 	results = Box.createVerticalBox();
 	scroll = new JScrollPane( results );
 
+	menu = new JPopupMenu("Menu");
+	menu_calendar = menu.add("Calendar board");
+	
+	context.setFont( new Font( "Monospaced", Font.BOLD, 16 ) );
+	create.setFont( new Font( "Monospaced", Font.BOLD, 16 ) );
 	field.setFont( new Font( "Monospaced", Font.PLAIN, 16 ) );
-	create.setFont( new Font( "Monospaced", Font.BOLD, 16 ) );
 
 	scroll.getVerticalScrollBar().setUnitIncrement(128);
 
@@ -62,13 +75,17 @@
 	
 	this.add( top, BorderLayout.NORTH );
 	top.add( field, BorderLayout.CENTER );
-	top.add( create, BorderLayout.EAST );
+	top.add( buttonBox, BorderLayout.EAST );
+	buttonBox.add( create );
+	buttonBox.add( context );
 
 	this.add( scroll, BorderLayout.CENTER );
 
 	scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
 
 	create.addActionListener(this);
+	context.addActionListener(this);
+	menu_calendar.addActionListener(this);
 
 	field.getDocument().addDocumentListener(
 						new DocumentListener()
@@ -98,6 +115,8 @@
 
 	field.setToolTipText("Search query.");
 	create.setToolTipText("Create new card. Shift-click to open it in a new window.");
+	context.setToolTipText("Bring up a menu with more actions.");
+	menu_calendar.setToolTipText("Open calendar board.");
 	
     }
 
@@ -199,6 +218,10 @@
 	} else if( source == create ) {
 	    boolean newWindow = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
 	    buttonClickedCreate( newWindow );
+	} else if( source == context ) {
+	    menu.show( (Component)source, 0, 0 );
+	} else if( source == menu_calendar ) {
+	    System.out.print("Calendar option selected!\n");
 	}
     }