Start to create a topPanel to add information.

This commit is contained in:
Mikael Capelle 2018-02-20 12:24:55 +01:00
parent 3a17f55571
commit 379784e2ec

View File

@ -114,7 +114,6 @@ public class MainWindow extends JFrame {
*/ */
public void enable(int nTargetPoints, CallableWithNodes callable) { public void enable(int nTargetPoints, CallableWithNodes callable) {
this.enabled = true; this.enabled = true;
MainWindow.this.getJMenuBar().setEnabled(false);
this.nTargetPoints = nTargetPoints; this.nTargetPoints = nTargetPoints;
this.points.clear(); this.points.clear();
this.callable = callable; this.callable = callable;
@ -125,7 +124,6 @@ public class MainWindow extends JFrame {
*/ */
public void disable() { public void disable() {
this.enabled = false; this.enabled = false;
MainWindow.this.getJMenuBar().setEnabled(true);
} }
public void mouseClicked(MouseEvent evt) { public void mouseClicked(MouseEvent evt) {
@ -182,7 +180,7 @@ public class MainWindow extends JFrame {
private JMenuItem openMapItem; private JMenuItem openMapItem;
// List of items that cannot be used without a graph // List of items that cannot be used without a graph
private ArrayList<JMenuItem> graphItems = new ArrayList<JMenuItem>(); private ArrayList<JMenuItem> graphLockItems = new ArrayList<JMenuItem>();
// Label containing the map ID of the current graph. // Label containing the map ID of the current graph.
private JLabel mapIdPanel; private JLabel mapIdPanel;
@ -247,6 +245,8 @@ public class MainWindow extends JFrame {
sp.add(new JScrollPane(infoPanel)); sp.add(new JScrollPane(infoPanel));
this.add(sp, BorderLayout.CENTER); this.add(sp, BorderLayout.CENTER);
// Top Panel
this.add(createTopPanel(), BorderLayout.NORTH);
this.add(createStatusBar(), BorderLayout.SOUTH); this.add(createStatusBar(), BorderLayout.SOUTH);
} }
@ -342,7 +342,7 @@ public class MainWindow extends JFrame {
drawing.clear(); drawing.clear();
new GraphDrawing(drawing).drawGraph(graph); new GraphDrawing(drawing).drawGraph(graph);
for (JMenuItem item: graphItems) { for (JMenuItem item: graphLockItems) {
item.setEnabled(true); item.setEnabled(true);
} }
mapIdPanel.setText("Map ID: 0x" + Integer.toHexString(graph.getMapId())); mapIdPanel.setText("Map ID: 0x" + Integer.toHexString(graph.getMapId()));
@ -388,7 +388,7 @@ public class MainWindow extends JFrame {
} }
} }
}); });
graphItems.add(openPathItem); graphLockItems.add(openPathItem);
// Close item // Close item
JMenuItem closeItem = new JMenuItem("Quit", KeyEvent.VK_Q); JMenuItem closeItem = new JMenuItem("Quit", KeyEvent.VK_Q);
@ -425,7 +425,7 @@ public class MainWindow extends JFrame {
}); });
} }
}); });
graphItems.add(drawGraphItem); graphLockItems.add(drawGraphItem);
JMenuItem drawGraphBWItem = new JMenuItem("Redraw (B&W)", KeyEvent.VK_B); JMenuItem drawGraphBWItem = new JMenuItem("Redraw (B&W)", KeyEvent.VK_B);
drawGraphBWItem.setAccelerator(KeyStroke.getKeyStroke( drawGraphBWItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_B, ActionEvent.ALT_MASK)); KeyEvent.VK_B, ActionEvent.ALT_MASK));
@ -442,7 +442,7 @@ public class MainWindow extends JFrame {
}); });
} }
}); });
graphItems.add(drawGraphBWItem); graphLockItems.add(drawGraphBWItem);
JMenu graphMenu = new JMenu("Graph"); JMenu graphMenu = new JMenu("Graph");
graphMenu.add(drawGraphItem); graphMenu.add(drawGraphItem);
@ -491,8 +491,8 @@ public class MainWindow extends JFrame {
} }
} }
}); });
graphItems.add(wccItem); graphLockItems.add(wccItem);
graphItems.add(bellmanItem); graphLockItems.add(bellmanItem);
algoMenu.add(wccItem); algoMenu.add(wccItem);
algoMenu.addSeparator(); algoMenu.addSeparator();
@ -507,7 +507,7 @@ public class MainWindow extends JFrame {
menuBar.add(graphMenu); menuBar.add(graphMenu);
menuBar.add(algoMenu); menuBar.add(algoMenu);
for (JMenuItem item: graphItems) { for (JMenuItem item: graphLockItems) {
item.setEnabled(false); item.setEnabled(false);
} }
@ -574,6 +574,12 @@ public class MainWindow extends JFrame {
return statusPanel; return statusPanel;
} }
protected JPanel createTopPanel() {
JPanel topPanel = new JPanel();
return topPanel;
}
public static void main(final String[] args) { public static void main(final String[] args) {
// Try to set system look and feel. // Try to set system look and feel.