title: JFrame help - passing value into PaintComponent()
body: <p>I've been working on a small "game" project for a while now and haven't been able to pass a value into my <code>paintComponent</code> method in any way.</p>
  
  <p>Here's my program. I used a <code>boolean test</code> parameter, but the <code>paintComponent</code> method does not consider <code>test</code> to be <code>true</code> and not paint the blue square.</p>
  
  <p>How can I fix this? Any help would be greatly appreciated.</p>
  
  <p>Class 1 (Swing):</p>
  
  <pre><code>package swing;
  
  import javax.swing.*;
  import javax.*;
  
  import java.awt.*;
  import java.awt.event.*;
  
  
  public class swing {
  
      private static  draw object = new draw();
  
      public static void main(String[] args) {
          JFrame frame = new JFrame("RogueLikeLike MVP");
          frame.setVisible(true);
          frame.setFocusable(true);
          frame.setSize(500,500);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);;
          frame.add(object); 
      }
  
  static class Move implements KeyListener{
  
  public boolean isFocusTraversable ( ) {
  return true;
  }
  
  public void keyPressed(KeyEvent e) {
      int x = 10;
      int y = 10;
      char c = e.getKeyChar();
      if(c == 's')
          y+=10;
      if(c == 'a')
          x-=10;
      if(c == 'w')
          y-=10;
      if(c == 'd')
          x+=10;
  
      object.setAlignmentX(x);
      object.setAlignmentY(y);
  
  }
  
  public void keyReleased(KeyEvent e) {}
  public void keyTyped(KeyEvent e) {}
  
  
  }
  }
  </code></pre>
  
  <p>Class 2 (draw):</p>
  
  <pre><code>package swing;
  
  import javax.swing.*;
  import java.awt.*;
  
  public class draw extends JPanel
  {
  
      boolean test = true;
  
      private static final long serialVersionUID = 1L;
  
      /*public void passMethod(draw object) {
          int x = (int) object.getAlignmentX();
          int y = (int) object.getAlignmentY();
      }*/
  
      public void drawing(draw object){
          draw thing = new draw();
          thing.setX(object.getAlignmentX());
          int x = 55;
          repaint();
      }
  
      private void setX(float alignmentX) {
          setX((int) alignmentX);
  
      }
  
      private void setY(float alignmentY) {
          setY((int) alignmentY);
  
      }
  
      public void paintComponent(Graphics g, boolean test){
          super.paintComponents(g);
          //int x = (int)object.getAlignmentX();
          //int y = (int)object.getAlignmentY();
          if(test==true)
          {
              g.setColor(Color.blue);
              g.fillRect(getX(),getY(),100,100);
          }
  
      }
  }
  </code></pre>