Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 56ecc61

Browse files
Update Algorithm.java
1 parent 63e252a commit 56ecc61

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

‎Algorithm.java‎

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import javax.swing.*;
22
import java.awt.*;
33
import java.awt.event.*;
4+
import java.util.*;
45

56

67
public class Algorithm extends JFrame{
7-
88
// Menu Bar
99
JMenuBar menuBar =new JMenuBar();
1010
JMenu mainMenu = new JMenu("Menu");
@@ -39,12 +39,52 @@ public static void main(String[] args){
3939
class ListenerClass implements ActionListener {
4040
String value;
4141

42+
// Project Main Logic (Moving Panels)
4243
public void actionPerformed(ActionEvent e) {
4344
if (e.getSource() == menu1) {
44-
System.out.println("KUKU");
45-
45+
Sorting sort = new Sorting();
4646
}
4747
}
4848
}
4949

5050
}
51+
52+
53+
class Sorting extends Algorithm{
54+
JFrame frameSorting = new JFrame("Sorting");
55+
// Values
56+
ArrayList<Integer> list=new ArrayList<Integer>();//Creating arraylist
57+
58+
// Sorting Buttons
59+
JButton jbtRandomize, jbtReset, jbtBubble, jbtInsertion, jbtSelection, jbtStart; // Sorting Buttons
60+
JPanel p1Sorting, p2Sorting;
61+
Random rand = new Random();
62+
63+
Sorting(){
64+
super();
65+
// Buttons for sorting
66+
jbtRandomize = new JButton("Randomize");//create button
67+
jbtReset = new JButton("Reset");//create button
68+
jbtBubble = new JButton("Bubble sort");//create button
69+
jbtInsertion = new JButton("Insertion sort");//create button
70+
jbtSelection = new JButton("Selection sort");//create button
71+
jbtStart = new JButton("Start");//create button
72+
73+
// Panel for buttons
74+
p1Sorting = new JPanel();
75+
p1Sorting.setLayout(new GridLayout(6,1));
76+
77+
// Adding Buttons to the panel
78+
p1Sorting.add(jbtRandomize); p1Sorting.add(jbtReset); p1Sorting.add(jbtSelection);
79+
p1Sorting.add(jbtBubble); p1Sorting.add(jbtInsertion); p1Sorting.add(jbtStart);
80+
81+
// Adding frame
82+
frameSorting.add(p1Sorting, BorderLayout.WEST);
83+
frameSorting.setTitle("Sorting");
84+
frameSorting.setSize(700,500);
85+
frameSorting.setLocation(200, 100);
86+
frameSorting.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
87+
frameSorting.setVisible(true);
88+
}
89+
90+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /