-
Notifications
You must be signed in to change notification settings - Fork 16
/
Application.java
94 lines (80 loc) · 3.15 KB
/
Application.java
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
85
86
87
88
89
90
91
92
93
94
package raven.application;
import com.formdev.flatlaf.FlatDarculaLaf;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.extras.FlatAnimatedLafChange;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import javax.swing.SwingUtilities;
import raven.application.form.LoginForm;
import raven.application.form.MainForm;
import raven.toast.Notifications;
/**
*
* @author Raven
*/
public class Application extends javax.swing.JFrame {
private static Application app;
private final MainForm mainForm;
private final LoginForm loginForm;
public Application() {
initComponents();
setSize(new Dimension(1200, 768));
setLocationRelativeTo(null);
mainForm = new MainForm();
loginForm = new LoginForm();
setContentPane(loginForm);
Notifications.getInstance().setJFrame(this);
}
public static void showForm(Component component) {
component.applyComponentOrientation(app.getComponentOrientation());
app.mainForm.showForm(component);
}
public static void login() {
FlatAnimatedLafChange.showSnapshot();
app.setContentPane(app.mainForm);
app.mainForm.applyComponentOrientation(app.getComponentOrientation());
setSelectedMenu(0, 0);
app.mainForm.hideMenu();
SwingUtilities.updateComponentTreeUI(app.mainForm);
FlatAnimatedLafChange.hideSnapshotWithAnimation();
}
public static void logout() {
FlatAnimatedLafChange.showSnapshot();
app.setContentPane(app.loginForm);
app.loginForm.applyComponentOrientation(app.getComponentOrientation());
SwingUtilities.updateComponentTreeUI(app.loginForm);
FlatAnimatedLafChange.hideSnapshotWithAnimation();
}
public static void setSelectedMenu(int index, int subIndex) {
app.mainForm.setSelectedMenu(index, subIndex);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setUndecorated(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 719, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 521, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
public static void main(String args[]) {
FlatLaf.registerCustomDefaultsSource("raven.theme");
FlatDarculaLaf.setup();
java.awt.EventQueue.invokeLater(() -> {
app = new Application();
// app.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
app.setVisible(true);
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}