1. Miguel García
  2. tailog

Commits

magmax  committed d75e503

changed the default layout by a JSplitPane

Comments (0)

Files changed (1)

File tailog/src/magmax/tailog/gui/MainWindow.java Modified

View file
  • Ignore whitespace
  • Hide word diff
 import javax.swing.JMenuItem;
 import javax.swing.JScrollPane;
 import javax.swing.JSeparator;
+import javax.swing.JSplitPane;
 import javax.swing.JTable;
 import javax.swing.JTree;
 
 	private JTable mainTable;
 	private ModelChangedLines mainModel;
 	private ModelFileTree modelFiles;
+	private JTable treeFiles;
 
 	private MainWindow() {
 		createMainFrame();
 		createMenu();
-		createFileBar();
 		createDesktop();
 		showMainFrame();
 	}
 	}
 
 	private void createDesktop() {
+		JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+		
+		createFileTable ();
+		createMainTable();
+		
+		JScrollPane scrollPanelMain = new JScrollPane(mainTable);
+		JScrollPane scrollPanelFiles = new JScrollPane(treeFiles);
+		
+		split.add (scrollPanelFiles);
+		split.add(scrollPanelMain);
+
+		
+		mainFrame.getContentPane().add(split, BorderLayout.CENTER);
+		mainFrame.pack();
+	}
+	
+	private void createFileTable ()
+	{
+		modelFiles = new ModelFileTree();
+		treeFiles = new JTable(modelFiles);
+		treeFiles.setVisible(true);
+	}
+	
+	private void createMainTable ()
+	{
 		mainModel = new ModelChangedLines();
 		mainTable = new JTable(mainModel);
 		mainTable.setPreferredSize(new Dimension(600, 400));
-		JScrollPane scrollPanel = new JScrollPane(mainTable);
 		mainTable.getColumnModel().getColumn(0).setPreferredWidth(20);
 		mainTable.setFillsViewportHeight(true);
-		mainFrame.getContentPane().add(scrollPanel, BorderLayout.CENTER);
-		mainFrame.pack();
 	}
 
 	private void createMenu() {
 		mainFrame.pack();
 	}
 
-	private void createFileBar() {
-
-		modelFiles = new ModelFileTree();
-		JTable tree = new JTable(modelFiles);
-		JScrollPane scrollPanel = new JScrollPane(tree);
-		tree.setVisible(true);
-		mainFrame.getContentPane().add(scrollPanel, BorderLayout.WEST);
-		mainFrame.pack();
-	}
 
 	class MenuBar extends JMenuBar {
 		private static final long serialVersionUID = 1L;
 		private JMenu getMenuEvents() {
 			JMenu result = new JMenu("Events");
 
-			JMenuItem open = new JMenuItem("Set Date Mark");
-			open.setAction(new SetDateMarkAction());
-			result.add(open);
+			JMenuItem dateMark = new JMenuItem("Set_Date_Mark");
+			dateMark.setAction(new SetDateMarkAction());
+			result.add(dateMark);
 			
 			JSeparator sep = new JSeparator();
 			result.add(sep);