-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.java
More file actions
84 lines (69 loc) · 3.04 KB
/
Application.java
File metadata and controls
84 lines (69 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// File: Application.java
import java.awt.*;
import javax.swing.*;
public class Application extends JFrame {
private Container cp;
private JMenuBar accountBar;
private MenuComponents menuComponents;
//private SearchBarPanel searchBarPanel;
//private BooksDisplay booksDisplay;
public static final int WINDOW_WIDTH = 900;
public static final int WINDOW_HEIGHT = 800;
public static final Color DARK_BG = Color.darkGray;
public static final Color PANEL_BG = Color.gray;
public static final Color ACCENT_COLOR = Color.WHITE;
public static final Color TEXT_COLOR = Color.black;
public Application() {
// Setup frame
setTitle("BookShelf - Digital Library");
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
// Setup container
cp = getContentPane();
cp.setLayout(new BorderLayout(10, 10));
cp.setBackground(DARK_BG);
((JPanel)cp).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
// Initialize components
menuComponents = new MenuComponents(this);
//searchBarPanel = new SearchBarPanel();
//booksDisplay = new BooksDisplay(this);
// Set menu bar
setJMenuBar(menuComponents.getMenuBar());
// Add components to frame
//cp.add(searchBarPanel, BorderLayout.NORTH);
//cp.add(booksDisplay, BorderLayout.CENTER);
// Add status bar
JPanel statusBar = createStatusBar();
cp.add(statusBar, BorderLayout.SOUTH);
setVisible(true);
}
private JPanel createStatusBar() {
JPanel statusBar = new JPanel(new BorderLayout());
statusBar.setBackground(PANEL_BG);
statusBar.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
JLabel statusLabel = new JLabel("Connected to BookShelf Library | 1000 books available");
statusLabel.setForeground(TEXT_COLOR);
statusLabel.setFont(new Font("Arial", Font.PLAIN, 12));
statusBar.add(statusLabel, BorderLayout.WEST);
JLabel versionLabel = new JLabel("v1.0.2");
versionLabel.setForeground(TEXT_COLOR);
versionLabel.setFont(new Font("Arial", Font.PLAIN, 12));
statusBar.add(versionLabel, BorderLayout.EAST);
return statusBar;
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// Set custom UI properties
UIManager.put("Menu.foreground", TEXT_COLOR);
UIManager.put("MenuItem.foreground", TEXT_COLOR);
UIManager.put("Menu.selectionBackground", ACCENT_COLOR);
UIManager.put("MenuItem.selectionBackground", ACCENT_COLOR);
UIManager.put("MenuItem.selectionForeground", TEXT_COLOR);
} catch (Exception e) {
e.printStackTrace();
}
SwingUtilities.invokeLater(Application::new);
}
}