-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSorting.java
More file actions
51 lines (38 loc) · 1.57 KB
/
Copy pathSorting.java
File metadata and controls
51 lines (38 loc) · 1.57 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Sorting extends JFrame {
// Values
ArrayList<Integer> list=new ArrayList<Integer>();//Creating arraylist
// Sorting Buttons
JButton jbtRandomize, jbtReset, jbtBubble, jbtInsertion, jbtSelection, jbtStart; // Sorting Buttons
JPanel p1Sorting, p2Sorting;
// Random Creator
Random rand = new Random();
// Progress Bar
JProgressBar jb1;
Sorting(){
// Buttons for sorting
jbtRandomize = new JButton("Randomize");//create button
jbtReset = new JButton("Reset");//create button
jbtBubble = new JButton("Bubble sort");//create button
jbtInsertion = new JButton("Insertion sort");//create button
jbtSelection = new JButton("Selection sort");//create button
jbtStart = new JButton("Start");//create button
jbtStart.setBackground(Color.GREEN);
// Panel for buttons
p1Sorting = new JPanel();
p1Sorting.setLayout(new GridLayout(6,1));
// Adding Buttons to the panel
p1Sorting.add(jbtRandomize); p1Sorting.add(jbtReset); p1Sorting.add(jbtSelection);
p1Sorting.add(jbtBubble); p1Sorting.add(jbtInsertion); p1Sorting.add(jbtStart);
jb1 = new JProgressBar(0,100);
jb1.setValue(rand.nextInt(100));
jb1.setStringPainted(true);
// Panel 2
p2Sorting = new JPanel();
p2Sorting.setLayout(new GridLayout(10,1));
p2Sorting.add(jb1, BorderLayout.WEST);
}
}