changeset 1:3922b33bb764

Separated tabs into classes
author Fox
date Fri, 01 Apr 2022 01:10:24 +0200
parents 4e9f2e87eb7b
children 19b163992f3b
files run.gui_sh src/Database.java src/Main.java src/junotu/Database.java src/junotu/Main.java src/junotu/TabEdit.java src/junotu/TabSimpleSearch.java
diffstat 5 files changed, 171 insertions(+), 136 deletions(-) [+]
line wrap: on
line diff
--- a/run.gui_sh	Fri Apr 01 00:32:11 2022 +0200
+++ b/run.gui_sh	Fri Apr 01 01:10:24 2022 +0200
@@ -1,11 +1,11 @@
 #!/bin/sh
 
 #export _JAVA_AWT_WM_NONREPARENTING=1
-export CLASSPATH=./build:./lib/lucene-core-3.0.3.jar
+export CLASSPATH=./src:./build:./lib/lucene-core-3.0.3.jar
 #JAVA=/usr/lib/jvm/java-8-openjdk-amd64/bin/java
 
 if [ ! -d 'build/' ]; then
 	mkdir build/
 fi
 
-javac -d build/ src/*.java && java Main
+javac -d ./build $(find . -name '*.java' | xargs) && java junotu.Main
--- a/src/Main.java	Fri Apr 01 00:32:11 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-
-import java.awt.Dimension;
-import java.awt.Font;
-
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-
-import java.awt.CardLayout;
-import java.awt.BorderLayout;
-import javax.swing.BoxLayout;
-
-import javax.swing.Box;
-import javax.swing.JButton;
-import javax.swing.JTextField;
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
-
-
-public class Main {
-
-    public enum Tab {
-	SEARCH,
-	EDIT,
-    };
-
-    public static final String PROGRAM_NAME = "Junotu";
-
-    private static final String[] TAB_NAMES = {
-	"Search",
-	"Edit",
-    };
-    
-    private static JFrame window;
-
-    private static JPanel tabs;
-    private static CardLayout tabsLayout;
-    private static JPanel search;
-    private static JPanel edit;
-
-    private static int activeTab = 0;
-    
-    public static void main(String[] args)
-    {
-
-	window = new JFrame();
-	panelsCreate();
-	tabSwitch(Tab.EDIT.ordinal());
-
-	window.setSize(384, 384);
-	//window.setLayout(null);
-	window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-	window.setVisible(true);
-    }
-
-    public static void tabSwitch( int tab )
-    {
-	tabsLayout.show(tabs, TAB_NAMES[tab]);
-	activeTab = tab;
-	window.setTitle(preferredTitle());
-    }
-    
-    private static void panelsCreate()
-    {
-
-	tabsLayout = new CardLayout();
-	tabs = new JPanel( tabsLayout );
-
-	panelsCreateSearch();
-	panelsCreateEdit();
-
-	window.add(tabs);
-	tabs.add(search);
-	tabs.add(edit);
-	tabsLayout.addLayoutComponent( search, TAB_NAMES[Tab.SEARCH.ordinal()] );
-	tabsLayout.addLayoutComponent( edit,   TAB_NAMES[Tab.EDIT.ordinal()] );
-	
-    }
-
-    private static void panelsCreateSearch()
-    {
-	search = new JPanel( new BorderLayout() );
-
-	JPanel top = new JPanel( new BorderLayout() );
-	JTextField field = new JTextField("Type here..");
-	JButton submit = new JButton("Search");
-
-	field.setPreferredSize( new Dimension(32, 32) );
-	
-	search.add( top, BorderLayout.NORTH );
-	top.add( field, BorderLayout.CENTER );
-	top.add( submit, BorderLayout.EAST );
-        
-    }
-
-    private static void panelsCreateEdit()
-    {
-	edit = new JPanel( new BorderLayout() );
-
-	Box scrollContent = Box.createVerticalBox();
-	JScrollPane scroll = new JScrollPane( scrollContent );
-	JTextField title = new JTextField( "Title" );
-	JTextArea content = new JTextArea( "Here you go. Some text." );
-
-        Box bottom = Box.createHorizontalBox();
-	JButton back = new JButton("Cancel");
-	JButton save = new JButton("Save");
-
-	title.setFont( new Font( "Monospaced", Font.PLAIN, 32 ) );
-	content.setFont( new Font( "Monospaced", Font.PLAIN, 16 ) );
-
-        scroll.getVerticalScrollBar().setUnitIncrement(16);
-
-	title.setMaximumSize( new Dimension( 1000000, 64 ) );
-
-	edit.add( scroll, BorderLayout.CENTER );
-	scrollContent.add( title );
-	scrollContent.add( Box.createVerticalStrut(10) );
-	scrollContent.add( content );
-
-	edit.add( bottom, BorderLayout.SOUTH );
-	bottom.add( back );
-	bottom.add( Box.createHorizontalGlue() );
-	bottom.add( save );
-
-	//scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
-	
-    }
-
-    private static String preferredTitle()
-    {
-	return PROGRAM_NAME+" - "+TAB_NAMES[activeTab];
-    }
-    
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/junotu/Main.java	Fri Apr 01 01:10:24 2022 +0200
@@ -0,0 +1,87 @@
+package junotu;
+
+import java.awt.Dimension;
+import java.awt.Font;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import java.awt.CardLayout;
+import java.awt.BorderLayout;
+import javax.swing.BoxLayout;
+
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JTextField;
+import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+
+import junotu.TabEdit;
+import junotu.TabSimpleSearch;
+
+public class Main {
+
+    public enum Tab {
+	SEARCH,
+	EDIT,
+    };
+
+    public static final String PROGRAM_NAME = "Junotu";
+
+    private static final String[] TAB_NAMES = {
+	"Search",
+	"Edit",
+    };
+    
+    private static JFrame window;
+
+    private static JPanel tabs;
+    private static CardLayout tabsLayout;
+    private static JPanel search;
+    private static JPanel edit;
+
+    private static int activeTab = 0;
+    
+    public static void main(String[] args)
+    {
+
+	window = new JFrame();
+	panelsCreate();
+	tabSwitch( Tab.SEARCH.ordinal() );
+	//tabSwitch( Tab.EDIT.ordinal() );
+
+	window.setSize(384, 384);
+	window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+	window.setVisible(true);
+    }
+
+    public static void tabSwitch( int tab )
+    {
+	tabsLayout.show(tabs, TAB_NAMES[tab]);
+	activeTab = tab;
+	window.setTitle(preferredTitle());
+    }
+    
+    private static void panelsCreate()
+    {
+
+	tabsLayout = new CardLayout();
+	tabs = new JPanel( tabsLayout );
+
+	search = new TabSimpleSearch();
+	edit = new TabEdit();
+
+	window.add(tabs);
+	tabs.add(search);
+	tabs.add(edit);
+	tabsLayout.addLayoutComponent( search, TAB_NAMES[Tab.SEARCH.ordinal()] );
+	tabsLayout.addLayoutComponent( edit,   TAB_NAMES[Tab.EDIT.ordinal()] );
+	
+    }
+
+    private static String preferredTitle()
+    {
+	return PROGRAM_NAME+" - "+TAB_NAMES[activeTab];
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/junotu/TabEdit.java	Fri Apr 01 01:10:24 2022 +0200
@@ -0,0 +1,50 @@
+package junotu;
+
+import java.awt.Dimension;
+import java.awt.Font;
+
+import javax.swing.JPanel;
+
+import java.awt.BorderLayout;
+
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JTextField;
+import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+
+public class TabEdit extends JPanel {
+    public TabEdit()
+    {
+	this.setLayout( new BorderLayout() );
+
+	Box scrollContent = Box.createVerticalBox();
+	JScrollPane scroll = new JScrollPane( scrollContent );
+	JTextField title = new JTextField( "Title" );
+	JTextArea content = new JTextArea( "Here you go. Some text." );
+
+        Box bottom = Box.createHorizontalBox();
+	JButton back = new JButton("Cancel");
+	JButton save = new JButton("Save");
+
+	title.setFont( new Font( "Monospaced", Font.PLAIN, 32 ) );
+	content.setFont( new Font( "Monospaced", Font.PLAIN, 16 ) );
+
+        scroll.getVerticalScrollBar().setUnitIncrement(16);
+
+	title.setMaximumSize( new Dimension( 1000000, 64 ) );
+
+	this.add( scroll, BorderLayout.CENTER );
+	scrollContent.add( title );
+	scrollContent.add( Box.createVerticalStrut(10) );
+	scrollContent.add( content );
+
+	this.add( bottom, BorderLayout.SOUTH );
+	bottom.add( back );
+	bottom.add( Box.createHorizontalGlue() );
+	bottom.add( save );
+
+	//scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+	
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/junotu/TabSimpleSearch.java	Fri Apr 01 01:10:24 2022 +0200
@@ -0,0 +1,32 @@
+package junotu;
+
+import java.awt.Dimension;
+import java.awt.Font;
+
+import javax.swing.JPanel;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JButton;
+import javax.swing.JTextField;
+import javax.swing.JScrollPane;
+
+public class TabSimpleSearch extends JPanel {
+    public TabSimpleSearch()
+    {
+	this.setLayout( new BorderLayout() );
+
+	JPanel top = new JPanel( new BorderLayout() );
+	JTextField field = new JTextField("Type here..");
+	JButton submit = new JButton("Search");
+
+	field.setFont( new Font( "Monospaced", Font.PLAIN, 16 ) );
+
+	field.setPreferredSize( new Dimension(32, 32) );
+	
+	this.add( top, BorderLayout.NORTH );
+	top.add( field, BorderLayout.CENTER );
+	top.add( submit, BorderLayout.EAST );
+	
+    }
+}