Repository navigation
Expand file tree
/
Copy pathHomePage.java
More file actions
143 lines (118 loc) · 4.64 KB
/
Copy pathHomePage.java
File metadata and controls
143 lines (118 loc) · 4.64 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class HomePage extends JFrame {
public HomePage() {
setTitle("Algorithm Simulator");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
JPanel panel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Image image = new ImageIcon("Bg.jpg").getImage();
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
};
panel.setLayout(new GridBagLayout());
JButton sortingButton = new JButton("Sorting");
JButton searchingButton = new JButton("Searching");
JButton insertionDeletionButton = new JButton("Insertion/Deletion");
JButton linkedListButton = new JButton("LinkedList Operations");
JButton aboutDeveloperButton = new JButton("About Developer");
Dimension buttonSize = new Dimension(120, 30);
sortingButton.setPreferredSize(buttonSize);
searchingButton.setPreferredSize(buttonSize);
insertionDeletionButton.setPreferredSize(buttonSize);
linkedListButton.setPreferredSize(buttonSize);
JLabel madeByLabel = new JLabel("Made By Ankit Raj");
madeByLabel.setHorizontalAlignment(JLabel.CENTER);
madeByLabel.setForeground(Color.RED);
JPanel labelPanel = new JPanel(new BorderLayout());
labelPanel.setOpaque(false);
labelPanel.add(madeByLabel, BorderLayout.CENTER);
add(panel, BorderLayout.CENTER);
add(labelPanel, BorderLayout.SOUTH);
panel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(10, 10, 10, 10);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
panel.add(sortingButton, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 1.0;
panel.add(searchingButton, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
panel.add(insertionDeletionButton, gbc);
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 1.0;
panel.add(linkedListButton, gbc);
sortingButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
redirectToSortingGUI();
}
});
searchingButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
redirectToSearchingGUI();
}
});
insertionDeletionButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openInsertionDeletionGUI();
}
});
linkedListButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openLinkedListOperationsGUI();
}
});
aboutDeveloperButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openAboutDeveloperGUI();
}
});
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1.0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(5, 10, 10, 10);
panel.add(aboutDeveloperButton, gbc);
}
private void redirectToSortingGUI() {
SortingAlgos sortingAlgos = new SortingAlgos();
sortingAlgos.setVisible(true);
}
private void redirectToSearchingGUI() {
Searching searching = new Searching();
searching.setVisible(true);
}
private void openInsertionDeletionGUI() {
Iad iad = new Iad();
iad.setVisible(true);
}
private void openLinkedListOperationsGUI() {
LinkedListOperations linkedListOperations = new LinkedListOperations();
linkedListOperations.setVisible(true);
}
private void openAboutDeveloperGUI() {
AboutDeveloper aboutDeveloper = new AboutDeveloper();
aboutDeveloper.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
HomePage homePage = new HomePage();
homePage.setSize(400, 200);
homePage.setVisible(true);
}
});
}
}