-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainPage.java
More file actions
100 lines (82 loc) · 2.78 KB
/
MainPage.java
File metadata and controls
100 lines (82 loc) · 2.78 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class MainPage extends JFrame{
final static int WINDOW_WIDTH = 500;
final static int WINDOW_HEIGHT = 500;
JButton start;
JButton info;
JFrame frame1;
JButton a;
JButton b;
Image image = null;
public MainPage() {
frame1 = new JFrame("CHS Course Selection Program");
frame1.setLayout(new GridLayout(3, 1));
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//set size
frame1.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
/*//logo
JPanel topRight = new JPanel(new GridLayout(1,3));
try {
BufferedImage icon = ImageIO.read(new File ("C:\\Suhani\\eclipse\\eclipse\\eclipse-workspace\\ChsCourseSelectionProgram\\src\\logo.jpg") );
ImageIcon logo = new ImageIcon(icon);
JLabel img = new JLabel(logo);
//img.setIcon(logo);
//topRight.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
topRight.add(img);
System.out.print("hi");
frame1.add(topRight);
} catch (IOException e) {
e.printStackTrace();
}*/
//ImageIcon imageLogo = new ImageIcon("logo.jpg");
//frame1.add(imageLogo);
JLabel label = new JLabel("");
ImageIcon logo = new ImageIcon(("src\\logo.jpg"));
Image image = logo.getImage();
image = image.getScaledInstance(500/3, 500/3, Image.SCALE_SMOOTH);
ImageIcon pic = new ImageIcon(image);
label.setIcon(pic);
label.setBackground(Color.WHITE);
label.setOpaque(true);
frame1.add(label);
//start button
a =new JButton("Start");//creating instance of JButton
JPanel aPanel = new JPanel();
aPanel.setBackground(Color.WHITE);
int x = a.getX();
int y = a.getY();
a.setSize(WINDOW_WIDTH/2, WINDOW_HEIGHT/2);
a.setAlignmentX(x+10);
a.setAlignmentY(y+10);
frame1.getContentPane().add(aPanel, "Center"); // Paste MyPanel in cent
aPanel.add(a);//adding button in JFrame
frame1.add(aPanel);
a.addActionListener(new choiceListener());
b=new JButton("Instructions");//creating instance of JButton
frame1.add(b, BorderLayout.CENTER);//adding button in JFrame
b.addActionListener(new choiceListener());
frame1.setVisible(true);//making the frame visible
}
private class choiceListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b) {
frame1.setVisible(false);//making the frame visible
new infoPage();
}
if (e.getSource() == a) {
frame1.setVisible(false);//making the frame visible
new DataGrade();
}
}
}
public static void main(String[] args) {
new MainPage();
}
}