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

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

Screen size adjustment for higher resolution monitors

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