|
1 | 1 | import javax.swing.*;
|
2 | 2 | import java.awt.*;
|
3 | 3 | import java.awt.event.*;
|
| 4 | +import java.util.*; |
4 | 5 |
|
5 | 6 |
|
6 | 7 | public class Algorithm extends JFrame{
|
7 |
| - |
8 | 8 | // Menu Bar
|
9 | 9 | JMenuBar menuBar =new JMenuBar();
|
10 | 10 | JMenu mainMenu = new JMenu("Menu");
|
@@ -39,12 +39,52 @@ public static void main(String[] args){
|
39 | 39 | class ListenerClass implements ActionListener {
|
40 | 40 | String value;
|
41 | 41 |
|
| 42 | + // Project Main Logic (Moving Panels) |
42 | 43 | public void actionPerformed(ActionEvent e) {
|
43 | 44 | if (e.getSource() == menu1) {
|
44 |
| - System.out.println("KUKU"); |
45 |
| - |
| 45 | + Sorting sort = new Sorting(); |
46 | 46 | }
|
47 | 47 | }
|
48 | 48 | }
|
49 | 49 |
|
50 | 50 | }
|
| 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