title: How to call in the paintScreen method in actionPerformed?
body: <p>So I've been tasked with adding 3 buttons of completely having the blinds open, having the button close the blind completely and close button. In the actionPerformed section I've tried calling the paintScreen method so that I can set the colour of the rectangle as cyan or grey but I've been finding it hard. Can you help and guide me to understanding how I could do this?</p>
  <pre><code>/**
   * A basic Java Swing application: a slider can be adjusted to open and close a &quot;blind&quot;.
   */
  
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import javax.swing.event.*;
  
  public class WindowBlind extends JFrame 
                           implements ChangeListener, ActionListener {
  
      /**
       * A slider to adjust a &quot;blind&quot;
       */
      private JSlider slider;
      /**
       * To record the current slider/blind setting
       */
      private int sliderValue = 0;
      /**
       * For drawing on
       */
      private JPanel panel;    
      
     private JButton closeButton=new JButton(&quot;Close Program&quot;);  
    
    
      private JButton openBlindCompletely=new JButton(&quot;Open Blinds&quot;);  
  
      
      private JButton closeBlindCompletely=new JButton(&quot;Close Blinds&quot;);  
  
      /**
       * The main method launches the application
       * @param args the command line arguments
       */
      public static void main(String[] args) {
          WindowBlind applic = new WindowBlind();
          applic.setLocation(100,100);
          applic.setVisible(true);
          
      }
  
      /**
       * Constructor - executed at instantiation of the class
       * Sets up the application's window
       */
      public WindowBlind() {
          
          setDefaultCloseOperation(EXIT_ON_CLOSE);
  
          setTitle(&quot;WindowBlind&quot;);
          setSize(300,300);
          
          add(closeButton);
          add(openBlindCompletely);
          add(closeBlindCompletely);
  
          Container window = getContentPane();
          window.setLayout(new FlowLayout());     // The default is that JFrame uses BorderLayout
  
          panel = new JPanel() {
                      // This paintComponent overrides the default one in JPanel (which does nothing).
                      // paintComponent is called automatically when a screen refresh is needed.
                      // The screen (Graphics parameter g) has already been cleared before paintComponent is called
                      public void paintComponent(Graphics g) {
                          super.paintComponent(g); // Paint the panel's background
                          paintScreen(g);          // Now do our custom drawing
                      } // paintComponent
                  };
          panel.setPreferredSize(new Dimension(200, 200));
          panel.setBackground(Color.white);
          window.add(panel);
  
          slider = new JSlider(JSlider.VERTICAL,0,100,0);
          slider.setInverted(true);               // 0 will be at top, not bottom, of vertical slider
          window.add(slider);
          slider.addChangeListener(this);         // Register for slider event
      } // constructor
  
      /**
       * Re-draws the window image: a &quot;blind&quot; covering a &quot;window&quot; through which the blue sky can be seen, referring to the global variable sliderValue to determine the blind size
       * @param g
       */
      public void paintScreen(Graphics g) {
          g.setColor(Color.cyan);
          g.fillRect(70, 40, 60, 100);         // The blue sky
          g.setColor(Color.lightGray);
          g.fillRect(70, 40, 60, sliderValue); // The blind, partially closed
          g.setColor(Color.black);
          g.drawRect(70, 40, 60, 100);   // The window frame
      
      } // paintScreen
  
      /**
       * When the slider is adjusted, this method is called automatically
       * @param e
       */
      public void stateChanged(ChangeEvent e) {
      sliderValue = slider.getValue();  // Fetch the slider's current setting
          repaint();                        // Force a screen refresh (paintComponent is called indirectly)
      } // stateChanged
  
      @Override
      public void actionPerformed(ActionEvent e) {
  
          if (e.getSource() == closeButton)
          {
              
          }
          
          if (e.getSource() == openBlindCompletely)
          {
              
          }
          
          if (e.getSource() == closeBlindCompletely)
          {
  
          }       
      }        
  }
  </code></pre>