Skip to content

Commit 1b09e61

Browse files
committed
updated
1 parent 0d6b30b commit 1b09e61

File tree

4 files changed

+77
-78
lines changed

4 files changed

+77
-78
lines changed

AlgorithmVisualizer.java

-78
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,3 @@
1-
import java.awt.*;
2-
import javax.swing.*;
3-
import java.awt.event.*;
4-
5-
class Menu extends JFrame {
6-
// Menubar
7-
static JMenuBar menuBar;
8-
9-
// JMenu
10-
static JMenu mainMenu, helpDesk;
11-
12-
// Menu items
13-
static JMenuItem menuItem1, menuItem2, menuItem3, menuItem4;
14-
15-
// A label
16-
static JLabel label;
17-
18-
Menu() {
19-
20-
// Create a label
21-
label = new JLabel("Welcome to Algorithm Visualizer!");
22-
23-
// Create a menubar
24-
menuBar = new JMenuBar();
25-
26-
// Create a menu
27-
mainMenu = new JMenu("Menu");
28-
helpDesk = new JMenu("Help");
29-
30-
// Create a menu items
31-
menuItem1 = new JMenuItem("Path Finding");
32-
menuItem2 = new JMenuItem("Sorting Techniques");
33-
menuItem3 = new JMenuItem("Puzzle Sorting");
34-
menuItem4 = new JMenuItem("How it Works");
35-
36-
ListenerClass listener = new ListenerClass();
37-
38-
// Register listeners
39-
menuItem1.addActionListener(listener);
40-
menuItem2.addActionListener(listener);
41-
menuItem3.addActionListener(listener);
42-
43-
// Add menu items to menu
44-
mainMenu.add(menuItem1);
45-
mainMenu.add(menuItem2);
46-
mainMenu.add(menuItem3);
47-
helpDesk.add(menuItem4);
48-
49-
// Add menu to menu bar
50-
menuBar.add(mainMenu);
51-
menuBar.add(helpDesk);
52-
53-
// Add menubar to frame
54-
setJMenuBar(menuBar);
55-
56-
// Add label
57-
add(label);
58-
59-
setTitle("EightSoft");
60-
setSize(400,400);
61-
// setLocation(200, 100);
62-
setVisible(true);
63-
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
64-
}
65-
66-
class ListenerClass implements ActionListener {
67-
String value;
68-
69-
// Project Main Logic (Moving Panels)
70-
public void actionPerformed(ActionEvent e) {
71-
if (e.getSource() == menuItem1) {
72-
label.setText("Wow Congratulations!");
73-
}
74-
}
75-
}
76-
77-
} // Menu
78-
791
public class AlgorithmVisualizer {
802
public static void main(String[] args){
813
new Menu();

Menu.java

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import java.awt.*;
2+
import javax.swing.*;
3+
import java.awt.event.*;
4+
5+
public class Menu extends JFrame {
6+
// Menubar
7+
static JMenuBar menuBar;
8+
9+
// JMenu
10+
static JMenu mainMenu, helpDesk;
11+
12+
// Menu items
13+
static JMenuItem menuItem1, menuItem2, menuItem3, menuItem4;
14+
15+
// A label
16+
static JLabel label;
17+
18+
Menu() {
19+
20+
// Create a label
21+
label = new JLabel("Welcome to Algorithm Visualizer!");
22+
23+
// Create a menubar
24+
menuBar = new JMenuBar();
25+
26+
// Create a menu
27+
mainMenu = new JMenu("Menu");
28+
helpDesk = new JMenu("Help");
29+
30+
// Create a menu items
31+
menuItem1 = new JMenuItem("Path Finding");
32+
menuItem2 = new JMenuItem("Sorting Techniques");
33+
menuItem3 = new JMenuItem("Puzzle Sorting");
34+
menuItem4 = new JMenuItem("How it Works");
35+
36+
ListenerClass listener = new ListenerClass();
37+
38+
// Register listeners
39+
menuItem1.addActionListener(listener);
40+
menuItem2.addActionListener(listener);
41+
menuItem3.addActionListener(listener);
42+
43+
// Add menu items to menu
44+
mainMenu.add(menuItem1);
45+
mainMenu.add(menuItem2);
46+
mainMenu.add(menuItem3);
47+
helpDesk.add(menuItem4);
48+
49+
// Add menu to menu bar
50+
menuBar.add(mainMenu);
51+
menuBar.add(helpDesk);
52+
53+
// Add menubar to frame
54+
setJMenuBar(menuBar);
55+
56+
// Add label
57+
add(label);
58+
59+
setTitle("EightSoft");
60+
setSize(400,400);
61+
// setLocation(200, 100);
62+
setVisible(true);
63+
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
64+
}
65+
66+
class ListenerClass implements ActionListener {
67+
String value;
68+
69+
// Project Main Logic (Moving Panels)
70+
public void actionPerformed(ActionEvent e) {
71+
if (e.getSource() == menuItem1) {
72+
label.setText("Wow Congratulations!");
73+
}
74+
}
75+
}
76+
77+
} // Menu
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)