2222
2323public class AlgVisualizer implements ActionListener {
2424
25- private final int CONTENT_WIDTH = 800 ;
26- private final int CONTENT_HEIGHT = 860 ;
27- private final int ARR_DISPLAY_HEIGHT = 800 ;
28- private final String [] SIZE_OPTIONS = { "10" , "50" , "100" , "200 " , "400 " , "800 " }; // array size options
25+ private final int CONTENT_WIDTH = 900 ;
26+ private final int CONTENT_HEIGHT = 960 ;
27+ private final int ARR_DISPLAY_HEIGHT = 900 ;
28+ private final String [] SIZE_OPTIONS = { "10" , "50" , "100" , "300 " , "450 " , "900 " }; // array size options
2929 private int n ;
3030 private int numSwaps ;
3131 private int delay ;
@@ -50,6 +50,7 @@ public class AlgVisualizer implements ActionListener {
5050 private JButton mergeButton ;
5151 private JButton quickButton ;
5252 private JComboBox <String > sizeChanger ;
53+ private JSlider FPSslider ;
5354 private JLabel performanceLabel ;
5455 private SwingWorker <Void , Integer []> arrSort ;
5556
@@ -135,6 +136,8 @@ public void initializeVars() {
135136 sizeChanger = new JComboBox <String >(SIZE_OPTIONS ); // Pass the String containing all of the size options
136137 sizeChanger .addActionListener (this );
137138 sizeChanger .setBackground (Color .WHITE );
139+
140+ FPSslider = new JSlider (JSlider .HORIZONTAL , 0 , 30 , 15 );
138141
139142 // Initialize the performance label and center it
140143
@@ -157,6 +160,7 @@ public void setFrame() {
157160 buttonPanel .add (mergeButton );
158161 buttonPanel .add (quickButton );
159162 buttonPanel .add (sizeChanger );
163+ buttonPanel .add (FPSslider );
160164
161165 // Initialize and make the frame visible
162166 frame = new JFrame ("Algorithm Visualizer" );
@@ -439,4 +443,12 @@ public int getDelay() {
439443 public void setDelay (int delay ) {
440444 this .delay = delay ;
441445 }
446+
447+ public JSlider getFPSslider () {
448+ return FPSslider ;
449+ }
450+
451+ public void setFPSslider (JSlider fPSslider ) {
452+ FPSslider = fPSslider ;
453+ }
442454}
0 commit comments