title: How to remove the blank JFrame from appearing?
body: <p>When I run my java program, two JFrames are showing, the JFrame that I created and another one that is blank that I cannot close. I think this error also has something to do with my JFrame that I created with components in it, not show when I run the program, instead the one showing is the blank JFrame. How do I fix this?</p>
  
  <pre><code>import java.awt.EventQueue;
  import java.awt.Frame;
  import java.awt.event.ActionEvent;
  
  import javax.swing.JFrame;
  import javax.swing.JOptionPane;
  import javax.swing.JButton;
  import javax.swing.Icon;
  import javax.swing.ImageIcon;
  import java.awt.event.ActionListener;
  import javax.swing.JLabel;
  import java.awt.Font;
  
  public class trial extends Frame implements ActionListener{
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
      private JFrame frame;
      JButton newButton1, newButton2, newButton3,newButton4,newButton5,newButton6,newButton7,newButton8,newButton9; 
      Icon ic1=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A1.png");
      Icon ic2=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A2.png");
      Icon ic3=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A3.png");
      Icon ic4=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A4.png");
      Icon ic5=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A5.png");
      Icon ic6=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A6.png");
      Icon ic7=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A7.png");
      Icon ic8=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\A8.png");
      Icon pink=new ImageIcon("C:\\Users\\DB\\Desktop\\eclipse\\JAVA\\Final Project\\img\\INSTRUMENTS\\c9.png");
      /**
       * Launch the application.
       */
      public static void main(String[] args) {
          EventQueue.invokeLater(new Runnable() {
              public void run() {
                  try {
                      trial window = new trial();
                      window.frame.setVisible(true);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          });
      }
  
      /**
       * Create the application.
       */
      public trial() {
          initialize();
      }
  
      /**
       * Initialize the contents of the frame.
       */
      private void initialize() {
          frame = new JFrame();
          frame.setBounds(100, 100, 986, 677);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().setLayout(null);
  
          newButton1 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A1.png"));
          newButton1.setBounds(43, 37, 150, 150);
  
          newButton2 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A2.png"));
          newButton2.setBounds(191,37, 150, 150);
  
          newButton3 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A3.png"));
          newButton3.setBounds(340,37, 150, 150);
  
          newButton4 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A4.png"));
          newButton4.setBounds(43,186, 150, 150); 
  
          newButton5 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A5.png"));
          newButton5.setBounds(191,186, 150, 150);
  
          newButton6 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A6.png"));
          newButton6.setBounds(340,186, 150, 150);
  
          newButton7 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A7.png"));
          newButton7.setBounds(43,335, 150, 150);
  
          newButton8 = new JButton(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\A8.png"));
          newButton8.setBounds(191,335,150, 150);
  
          newButton9 = new JButton(pink);
          newButton9.setBounds(340,335,150, 150);
  
  
          newButton1.addActionListener(this); 
          newButton2.addActionListener(this);  
          newButton3.addActionListener(this);  
          newButton4.addActionListener(this);  
          newButton5.addActionListener(this);  
          newButton6.addActionListener(this);  
          newButton7.addActionListener(this);  
          newButton8.addActionListener(this);  
          newButton9.addActionListener(this);
  
          frame.getContentPane().add(newButton1);frame.getContentPane().add(newButton2);frame.getContentPane().add(newButton3);frame.getContentPane().add(newButton4);frame.getContentPane().add(newButton5);frame.getContentPane().add(newButton6);
          frame.getContentPane().add(newButton7);frame.getContentPane().add(newButton8);frame.getContentPane().add(newButton9);
  JButton btnNewButton = new JButton("");
  btnNewButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
  
          dispose();
          DrumInfo a = new DrumInfo();
          a.setLocationRelativeTo(null);
          a.setVisible(true);
  
      }
  });
  btnNewButton.setIcon(new ImageIcon("C:\\Users\\jaxma\\Documents\\JAVA\\Final Project\\img\\INSTRUMENTS\\drums.png"));
  btnNewButton.setBounds(597, 37, 300, 277);
  frame.getContentPane().add(btnNewButton);
  JLabel lblNewLabel = new JLabel("Click the picture to find out what's the picture about!");
  lblNewLabel.setFont(new Font("Berlin Sans FB Demi", Font.PLAIN, 15));
  lblNewLabel.setBounds(563, 315, 382, 45);
  frame.getContentPane().add(lblNewLabel);
  JButton btnNewButton_1 = new JButton("BACK");
  btnNewButton_1.setBounds(412, 563, 156, 63);
  frame.getContentPane().add(btnNewButton_1);
  JButton btnCategories = new JButton("CATEGORIES");
  btnCategories.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  
          dispose();
          Puzzle2 a = new Puzzle2();
          a.setLocationRelativeTo(null);
          a.setVisible(true);
  
      }
  });
  btnCategories.setBounds(604, 563, 156, 63);
  frame.getContentPane().add(btnCategories);
  JButton btnNext = new JButton("NEXT");
  btnNext.setBounds(789, 563, 156, 63);
  frame.getContentPane().add(btnNext);
  
          setSize(600,500);  
          setLayout(null);  
          setVisible(true);  
  
  
      }  
      public void actionPerformed(ActionEvent e){  
          if(e.getSource()==newButton1){  
              Icon s1 = newButton1.getIcon();
              if(newButton2.getIcon().equals(pink)) {
                  newButton2.setIcon(s1);
                  newButton1.setIcon(pink);
              }
              if(newButton4.getIcon().equals(pink)) {
                  newButton4.setIcon(s1);
                  newButton1.setIcon(pink);
              }
  
          }  
          if(e.getSource()==newButton2){  
              Icon s1 = newButton2.getIcon();
              if(newButton1.getIcon().equals(pink)) {
                  newButton1.setIcon(s1);
                  newButton2.setIcon(pink);
              }
              if(newButton3.getIcon().equals(pink)) {
                  newButton3.setIcon(s1);
                  newButton2.setIcon(pink);
              }
              if(newButton5.getIcon().equals(pink)) {
                  newButton5.setIcon(s1);
                  newButton2.setIcon(pink);
              }
  
          }  
          if(e.getSource()==newButton3){  
              Icon s1 = newButton3.getIcon();
              if(newButton2.getIcon().equals(pink)) {
                  newButton2.setIcon(s1);
                  newButton3.setIcon(pink);
              }
              if(newButton6.getIcon().equals(pink)) {
                  newButton6.setIcon(s1);
                  newButton3.setIcon(pink);
              }
  
          }  
          if(e.getSource()==newButton4){  
              Icon s1 = newButton4.getIcon();
              if(newButton1.getIcon().equals(pink)) {
                  newButton1.setIcon(s1);
                  newButton4.setIcon(pink);
              }
              if(newButton7.getIcon().equals(pink)) {
                  newButton7.setIcon(s1);
                  newButton4.setIcon(pink);
              }
              if(newButton5.getIcon().equals(pink)) {
                  newButton5.setIcon(s1);
                  newButton4.setIcon(pink);
              }
  
          }  
          if(e.getSource()==newButton5){  
              Icon s1 = newButton5.getIcon();
              if(newButton2.getIcon().equals(pink)) {
                  newButton2.setIcon(s1);
                  newButton5.setIcon(pink);
              }
              if(newButton6.getIcon().equals(pink)) {
                  newButton6.setIcon(s1);
                  newButton5.setIcon(pink);
              }
              if(newButton4.getIcon().equals(pink)) {
                  newButton4.setIcon(s1);
                  newButton5.setIcon(pink);
              }
              if(newButton8.getIcon().equals(pink)) {
                  newButton8.setIcon(s1);
                  newButton5.setIcon(pink);
              }
  
          }  
          if(e.getSource()==newButton6){  
              Icon s1 = newButton6.getIcon();
              if(newButton9.getIcon().equals(pink)) {
                  newButton9.setIcon(s1);
                  newButton6.setIcon(pink);
              }
              if(newButton3.getIcon().equals(pink)) {
                  newButton3.setIcon(s1);
                  newButton6.setIcon(pink);
              }
              if(newButton5.getIcon().equals(pink)) {
                  newButton5.setIcon(s1);
                  newButton6.setIcon(pink);
              }
  
          }  
          if(e.getSource()==newButton7){  
              Icon s1 = newButton7.getIcon();
              if(newButton4.getIcon().equals(pink)) {
                  newButton4.setIcon(s1);
                  newButton7.setIcon(pink);
              }
              if(newButton8.getIcon().equals(pink)) {
                  newButton8.setIcon(s1);
                  newButton7.setIcon(pink);
              }
  
          }
          if(e.getSource()==newButton8){  
              Icon s1 = newButton8.getIcon();
              if(newButton9.getIcon().equals(pink)) {
                  newButton9.setIcon(s1);
                  newButton8.setIcon(pink);
              }
              if(newButton7.getIcon().equals(pink)) {
                  newButton7.setIcon(s1);
                  newButton8.setIcon(pink);
              }
              if(newButton5.getIcon().equals(pink)) {
                  newButton5.setIcon(s1);
                  newButton8.setIcon(pink);
              }
  
          }  
          if(e.getSource()==newButton9){  
              Icon s1 = newButton9.getIcon();
              if(newButton6.getIcon().equals(pink)) {
                  newButton6.setIcon(s1);
                  newButton9.setIcon(pink);
              }
              if(newButton8.getIcon().equals(pink)) {
                  newButton8.setIcon(s1);
                  newButton9.setIcon(pink);
              }
  
          }
          if(newButton1.getIcon().equals(ic1)&amp;&amp;newButton2.getIcon().equals(ic2)&amp;&amp;newButton3.getIcon().equals(ic3)&amp;&amp;newButton4.getIcon().equals(ic4)&amp;&amp;newButton5.getIcon().equals(ic5)&amp;&amp;newButton6.getIcon().equals(ic6)&amp;&amp;newButton7.getIcon().equals(ic7)&amp;&amp;newButton8.getIcon().equals(ic8)&amp;&amp;newButton9.getIcon().equals(pink)) {
               JOptionPane.showMessageDialog(this,"Congratulations! You won.");    
          }
  
  
      }  
  }
  </code></pre>