title: Simple GUI | JButton, when pressed, displays text with string variable defined by another class' method | Debug help, please?
body: <pre><code>****// --------------------------------
  package Practice;
  import java.util.Random;
  
  public class Card
  {
      Random gen = new Random();
      private Card[] Deck = new Card[60];
      private int i = 0;
      private int drawnCard;
      public static String cardName = "";
  
      // Constructor to return String variable "cardName",    
      // which is later used by the MTGgui class.
      public String Draw(String cardName)
      {   
          if (i &lt; Deck.length)
          {
              drawnCard = gen.nextInt(5) + 0;
  
              switch (drawnCard)
              {
              case 0: cardName = "Instant";
              case 1: cardName = "Sorcery";
              case 2: cardName = "Creature";
              case 3: cardName = "Enchantment";
              case 4: cardName = "Land";
              case 5: cardName = "Artifact";
              default: cardName = "Nothing!";
              }
  
              Card.cardName = this.cardName;
          }
          return Card.cardName;
      }
  }
  // Card class.
  //--------------------------------
  
  
  
  
  // --------------------------------
  package Practice;
  import javax.swing.JFrame;
  
  public class MTGInterface extends JFrame
  {
      public static void main (String[] args)
      {
          MTGgui MTG = new MTGgui();
          MTG.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          MTG.setSize(300, 200);
          MTG.setVisible(true);
      }
  }
  
  // Main class.
  // --------------------------------
  
  
  
  
  // --------------------------------------------------
  package Practice;
  import java.awt.FlowLayout;
  import java.awt.event.ActionListener;
  import java.awt.event.ActionEvent;
  
  import javax.swing.JFrame;
  import javax.swing.JButton;
  import javax.swing.Icon;
  import javax.swing.ImageIcon;
  import javax.swing.JOptionPane;
  // Importing required assets.
  
  public class MTGgui extends JFrame // Code to set up the user interface.
  {
      // JButton variable that appears on-screen.
      private JButton DrawCard;
  
      // Constructor for this class.
      public MTGgui()
      {
          super("MTG Deck Drawing Simulator : Mega Awesome Edition!!!");
  
          setLayout(new FlowLayout());
  
          DrawCard = new JButton("Draw a card");
          add(DrawCard);
  
          // Building an event handler for actions caused by button.
          HandlerClass Handler = new HandlerClass();
          DrawCard.addActionListener(Handler);
      }
  
      // Private class within MTGgui for event handling.
      private class HandlerClass implements ActionListener
      {
          // Initializing private String variable that is the same 
          // as the "Card" class' variable - cardName.
          private String card = Card.cardName;
  
          public void actionPerformed(ActionEvent Event) 
          {
              JOptionPane.showMessageDialog(null, "You drew a(n)" + card);
          }
  
      }
  }
  
  // MTGgui class
  //--------------------------------------------------****
  </code></pre>
  
  <p>Essentially, I've created a program that is intended to provide the user with an interface containing one button. When the button is pressed, the program is supposed to generate a string based on a simple random variable and a switch case, then display "You drew a(n) " + that string variable.</p>
  
  <p>Everything functions as intended, except that the method "showDialogMessage" in the MTGgui class, when called, is not displaying the String "cardName", which is defined as another private variable called "card" in its respective class. Any suggestions on how to fix this?</p>