source: src/main/java/genius/gui/MainPanel.java@ 209

Last change on this file since 209 was 199, checked in by Tim Baarslag, 5 years ago

60s timeout default

File size: 2.7 KB
Line 
1package genius.gui;
2
3import java.awt.BorderLayout;
4import java.awt.Component;
5import java.awt.Dimension;
6import java.awt.Frame;
7import java.awt.event.MouseEvent;
8
9import javax.swing.JFrame;
10import javax.swing.JMenu;
11import javax.swing.JMenuBar;
12import javax.swing.JScrollPane;
13import javax.swing.JSplitPane;
14import javax.swing.JTabbedPane;
15
16import genius.gui.actions.AboutAction;
17import genius.gui.actions.OpenManual;
18import genius.gui.actions.Session;
19import genius.gui.actions.Tournament;
20import genius.gui.boaframework.BOARepositoryUI;
21import genius.gui.boaparties.BoaPartiesPanel;
22import genius.gui.domainrepository.DomainRepositoryUI;
23import genius.gui.panels.tab.CloseTabbedPane;
24import genius.gui.repository.PartyRepositoryUI;
25
26/**
27 * main application and main GUI panel.
28 *
29 */
30@SuppressWarnings("serial")
31public class MainPanel extends JFrame implements GeniusAppInterface {
32
33 private JTabbedPane repoArea = new JTabbedPane();
34 private CloseTabbedPane editArea = new CloseTabbedPane();
35
36 public MainPanel() {
37 setLayout(new BorderLayout());
38 setMinimumSize(new Dimension(1280, 1024));
39 String version = getClass().getPackage().getImplementationVersion();
40 if (version != null) // if the version is defined in the MANIFEST file, e.g. Genius is in a .jar
41 setTitle("GENIUS " + version);
42 else
43 setTitle("GENIUS");
44 JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
45 repoArea, editArea);
46 splitpane.setDividerLocation(300);
47
48 add(splitpane, BorderLayout.CENTER);
49 repoArea.addTab("Domains",
50 new JScrollPane(new DomainRepositoryUI(this)));
51 repoArea.addTab("BOA Components",
52 new JScrollPane(new BOARepositoryUI(this)));
53 repoArea.addTab("Parties", new PartyRepositoryUI());
54 repoArea.addTab("Boa Parties", new BoaPartiesPanel());
55
56 setJMenuBar(new MenuBar(this));
57
58 editArea.addCloseListener((MouseEvent e, int overTabIndex) -> editArea
59 .remove(overTabIndex));
60 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
61 }
62
63 /**
64 * For testing
65 */
66 public static void main(String[] args) {
67 MainPanel mainpanel = new MainPanel();
68
69 mainpanel.pack();
70 mainpanel.setVisible(true);
71
72 }
73
74 @Override
75 public void addTab(String title, Component comp) {
76 editArea.addTab(title, comp);
77 editArea.setSelectedComponent(comp);
78 }
79
80 @Override
81 public Frame getMainFrame() {
82 return this;
83 }
84}
85
86@SuppressWarnings("serial")
87class MenuBar extends JMenuBar {
88 private JMenu startMenu = new JMenu();
89 private JMenu helpMenu = new JMenu();
90
91 public MenuBar(GeniusAppInterface mainPanel) {
92 startMenu.setText("Start");
93 startMenu.add(new Session(mainPanel));
94 startMenu.add(new Tournament(mainPanel));
95
96 add(startMenu);
97
98 helpMenu.setText("Help");
99 helpMenu.add(new OpenManual());
100 helpMenu.add(new AboutAction());
101 add(helpMenu);
102 }
103}
Note: See TracBrowser for help on using the repository browser.