title: How to make a class extending a jLabel so that it appears as a JLabel in my main class?
body: <p>So, essentially I'm making memory. I have  a tile class, which at this point will only have a number, and a boolean (to show if it is flipped or not). I made duplicates of all the numbers as Tile objects and randomized them, and in turn added them to my layout. </p>
  
  <p>Basically, I need them to show up on my screen as JLabels, and I'm not exactly sure how to do this? Should I be extending something else, or do something special in my Tile class? Or is it a problem with my logic elsewhere? Here's my Tile class at this point (very little)</p>
  
  <p>PS. I also need to use a timer for the flippy flop</p>
  
  <pre><code>class Tile extends JLabel implements ActionListener{
  
  boolean flipped;
  int imageNum;
  ImageIcon image;
  JLabel card;
  
  Tile(int num, boolean f)
  {
      imageNum=num;
      flipped=f;
      card=new JLabel(""+imageNum);
  }
  public void flipCard()
  {
  
  }
  
  public void actionPerformed(ActionEvent a)
  {
  
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated!
   EDIT:</p>
  
  <p>Here's the main  class where I try to add my tiles</p>
  
  <pre><code>JPanel gridPanel = new JPanel(new GridLayout(gridSize, gridSize));
      Tile[][]tiles=new Tile[(gridSize*gridSize)/2][2];
      boolean[][]tilePlaced=new boolean[(gridSize*gridSize)/2][2];
      JLabel[][] cardsOnGrid = new JLabel[gridSize][gridSize];
      for(int i=0;i&lt;gridSize;i++)
      {
          for(int j=0;j&lt;gridSize;j++)
              cardsOnGrid[i][j]=new JLabel("");
      }
      for(int i=0; i&lt;((gridSize*gridSize)/2);i++)
      {
          tiles[i][0]= new Tile(i, true);
          tiles[i][1]= new Tile(i, true);
          tilePlaced[i][0]=false;
          tilePlaced[i][1]=false;
      }
  
      for(int i=0; i&lt;gridSize;i++)
      {
          for(int j=0;j&lt;gridSize;j++)
          {
              int tileNum = tileRandom(gridSize);
              int tileNumVer = (int)Math.floor(Math.random()*2);
              while(tilePlaced[tileNum][tileNumVer]==true)
              {
                  tileNum = tileRandom(gridSize);
                  tileNumVer = (int)Math.floor(Math.random()*2);
              }
              gridPanel.add(tiles[tileNum][tileNumVer]);
              tilePlaced[tileNum][tileNumVer]=true;
          }
  </code></pre>
  
  <p>:'(</p>