title: Java Gridbag layout fillPolygon not displaying?
body: <p>How come the polygon I tell my program to display. Here is my code of the class I call.</p>
  
  <pre><code>package rubiksCube;
  /*class that contains my paint component*/
  import java.awt.*;
  import javax.swing.JPanel;
  public class Display extends JPanel{
      Polygon[][] p = {{new Polygon(),new Polygon(),new Polygon()},
                      {new Polygon(),new Polygon(),new Polygon()},
                      {new Polygon(),new Polygon(),new Polygon()}};
      int[] rx = {0,0,0,0};
      int[] ry = {0,0,0,0};
      int rsN = 0;
      public void renderSide(int sN,int[] x,int[] y){
          rsN = sN;
          ry = y;
          rx = x;
      }
      public void paintComponent(Graphics g){
          g.clearRect(0, 0, 100, 100);
          for(int y = 0;y&lt;3;y++){
              for(int x = 0;x&lt;3;x++){
                  System.out.print(x);
                  System.out.println(y);
                  g.setColor(getColor(Main.j[rsN][(y*3)+x]));
                  p[y][x].addPoint((((rx[0]-rx[3])*(y/3)+rx[0])-((rx[1]-rx[2]))*(y/3)+rx[1])*(x/3)+((rx[0]-rx[3])*(y/3)+rx[0]),((((ry[0]-ry[3])*(x/3)+ry[0])-((ry[1]-ry[2]))*(x/3)+ry[1]))*(y/3)+((ry[0]-ry[3])*(x/3)+ry[0]));
                  p[y][x].addPoint((((rx[0]-rx[3])*(y/3)+rx[0])-((rx[1]-rx[2]))*(y/3)+rx[1])*(x+1/3)+((rx[0]-rx[3])*(y/3)+rx[0]),((((ry[0]-ry[3])*(x/3)+ry[0])-((ry[1]-ry[2]))*(x/3)+ry[1])*(y/3))+((ry[0]-ry[3])*(x/3)+ry[0]));
                  p[y][x].addPoint((((rx[0]-rx[3])*(y/3)+rx[0])-((rx[1]-rx[2]))*(y/3)+rx[1])*(x+1/3)+((rx[0]-rx[3])*(y/3)+rx[0]),((((ry[0]-ry[3])*(x/3)+ry[0])-((ry[1]-ry[2]))*(x/3)+ry[1]))*(y+1/3)+((ry[0]-ry[3])*(x/3)+ry[0]));
                  p[y][x].addPoint((((rx[0]-rx[3])*(y/3)+rx[0])-((rx[1]-rx[2]))*(y/3)+rx[1])*(x/3)+((rx[0]-rx[3])*(y/3)+rx[0]),((((ry[0]-ry[3])*(x/3)+ry[0])-((ry[1]-ry[2]))*(x/3)+ry[1]))*(y+1/3)+((ry[0]-ry[3])*(x/3)+ry[0]));
                  g.fillPolygon(p[y][x]);
              }
          }
      }
      public Color getColor(int i){
          switch(i){
              case 0:
              return Color.WHITE;
              case 1:
              return Color.GREEN;
              case 2:
              return Color.RED;
              case 3:
              return Color.YELLOW;
              case 4:
              return Color.BLUE;
  
          }
          return Color.ORANGE;
      }
  }
  //my main class
  package rubiksCube;
  
  import java.awt.Graphics;
  
  import javax.swing.JFrame;
  
  public class Main {
  
      public static int[][] j = {
              {0,0,0,0,0,0,0,0,0},
              {1,1,1,1,1,1,1,1,1},
              {2,2,2,2,2,2,2,2,2},
              {3,3,3,3,3,3,3,3,3},
              {4,4,4,4,4,4,4,4,4},
              {5,5,5,5,5,5,5,5,5}
      };
      public static void main(String args[]){
              SimpleGui s = new SimpleGui();
              Display d = new Display();
              int[] x = {0,100,100,0};
              int[] y = {0,0,100,100};
              d.renderSide(0,x,y);
              s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              s.pack();
              s.setSize(1000,700);
              s.setVisible(true);
              s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              s.pack();
              s.setSize(1000,1000);
              s.setVisible(true);
  
      }
  
  }
      //and my gui class
  package rubiksCube;
  
  import java.awt.*;
  import java.awt.event.*;
  
  import javax.swing.*;
  
  
  public class SimpleGui  extends JFrame{
          int[] px2;
          int[] py2;
          int[] pz2;
          Graphics g2 = null;
          int sN;
  
  
      public SimpleGui(){
          JButton solve = new JButton();
          JPanel p = new JPanel();
          solve.setText("Solve");
          solve.addActionListener(new ActionListener(){
  
          public void actionPerformed(ActionEvent e){
              Control c = new Control();
              c.solve();
          }});
          solve.addKeyListener(new KeyListener(){
  
  
              public void keyPressed(KeyEvent k) {
                  switch (k.getKeyCode()){
                  case KeyEvent.VK_DOWN:
  
                      break;
                  case KeyEvent.VK_UP:
  
                      break;
                  case KeyEvent.VK_LEFT:
  
                      break;
                  case KeyEvent.VK_RIGHT:
  
                      break;
                  case KeyEvent.VK_0:
  
                      break;
                  case KeyEvent.VK_1:
  
                      break;
                  case KeyEvent.VK_2:
  
                      break;
                  case KeyEvent.VK_3:
  
                      break;
                  case KeyEvent.VK_4:
  
                      break;
                  case KeyEvent.VK_5:
  
                      break;
                  case KeyEvent.VK_6:
  
                      break;
                  case KeyEvent.VK_7:
  
                      break;
                  case KeyEvent.VK_8:
  
                      break;
                  case KeyEvent.VK_9:
  
                      break;
                  case KeyEvent.VK_MINUS:
  
                      break;
                  case KeyEvent.VK_EQUALS:
  
                      break;
  
                  }
  
  
              }
  
  
              public void keyReleased(KeyEvent k) {
  
  
              }
  
  
              public void keyTyped(KeyEvent k) {
  
  
              }
  
          });
          JButton random = new JButton();
          random.setText("Randomize");
          random.addActionListener(new ActionListener(){
  
          public void actionPerformed(ActionEvent e){
              Control c = new Control();
              c.random();
          }});
          p.setVisible(true);
          p.setLayout(new GridBagLayout());
          solve.setVisible(true);
          random.setVisible(true);
          GridBagConstraints c = new GridBagConstraints();
          c.weightx = 1;
          c.weighty = 1;
          c.gridx = 0;
          c.gridy = 0;
          c.anchor = GridBagConstraints.FIRST_LINE_START;
          p.add(solve,c);
          c.anchor = GridBagConstraints.PAGE_START;
          c.gridx = 0;
          c.gridy = 0;
          p.add(random,c);
          c.anchor = GridBagConstraints.FIRST_LINE_START;
          c.gridx = 2;
          c.gridy = 2;
          JPanel d = new Display();
          d.setPreferredSize(new Dimension(100,100));
          p.add(d,c);
          add(p);
          setContentPane(p);
          setVisible(true);
      }}
  </code></pre>
  
  <p>Can someone please explain that when i say g.fillPolyon(p[y][x]); it doesn't work?
  Help please appreciated.
  This is on line 23 of my display class.</p>