-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubject.java
113 lines (88 loc) · 3.14 KB
/
Subject.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author abhiram
*/
import java.awt.*;
import java.awt.event.*;
public class Subject extends java.awt.Frame {
static String Subject;
/**
* Creates new form Subject
*/
public Subject() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
btnChemistry = new javax.swing.JButton();
btnPhysics = new javax.swing.JButton();
lblSelectSubject = new javax.swing.JLabel();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
setLayout(new FlowLayout());
setSize(1000,1000);
btnChemistry.setText("Chemistry");
btnChemistry.setActionCommand("chem");
add(btnChemistry);
btnChemistry.setBounds(151, 125, 89, 25);
btnChemistry.addActionListener(new ButtonClickListener());
btnPhysics.setText("Physics");
btnPhysics.setActionCommand("phy");
add(btnPhysics);
btnPhysics.setBounds(151, 181, 89, 25);
btnPhysics.addActionListener(new ButtonClickListener());
lblSelectSubject.setText("Select a Subject");
add(lblSelectSubject);
lblSelectSubject.setBounds(105, 42, 182, 16);
setLayout(null);
}// </editor-fold>//GEN-END:initComponents
/**
* Exit the Application
*/
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Subject().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnChemistry;
private javax.swing.JButton btnPhysics;
private javax.swing.JLabel lblSelectSubject;
// End of variables declaration//GEN-END:variables
public class ButtonClickListener implements ActionListener{
public void actionPerformed(ActionEvent e){
String command = e.getActionCommand();
if(command.equals("phy")){
btnPhysics.getParent().setVisible(false);
new PhysicsHomePage(command).setVisible(true);
Subject = command;
}
else{
btnChemistry.getParent().setVisible(false);
new PhysicsHomePage(command).setVisible(true);
Subject = command;
}
}
}
}