I'm having issues opening a new jframe window on click. I think I'm doing it right, but I'm not sure. in the action listener (in first class listed below)
testing2 test = new testing2();
                testing2.setVisible(true);
but the testing2.setVisible(true) says "Cannot make a static reference to the non-static method setVisible(boolean) from the type JComponent" Any help is appreciated.
import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    /*************************************************************
         *  TextPanel Class (with main method)
     *************************************************************/
    class testing2 extends JPanel {
        public testing2() {
            JButton btnTesting = new JButton("Testing 2");
            add(btnTesting);
        }
      // override the paintComponent method
      // THE MAIN DEMO OF THIS EXAMPLE:
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Font f = new Font("SansSerif", Font.BOLD, 14);
        Font fi = new Font("SansSerif", Font.BOLD + Font.ITALIC, 14);
        FontMetrics fm = g.getFontMetrics(f);
        FontMetrics fim = g.getFontMetrics(fi);
        int cx = 75; int cy = 100;
        g.setFont(f);
        g.drawString("Hello, ", cx, cy);
        cx += fm.stringWidth("Hello, ");
        g.setFont(fi);
        g.drawString("World!", cx, cy);
      } //paintComponent
      //=============================================
      ///////////// main ////////////////////////////
      public static void main(String[] args) {
        JFrame f = new MyFrame("My Hello World Frame");
        f.show();
      } //main
    } //class TextPanel
    /*************************************************************
            MyFrame Class
     *************************************************************/
    class MyFrame extends JFrame {
      public MyFrame(String s) {
        // Frame Parameters
        setTitle(s);
        setSize(300,200); // default size is 0,0
        setLocation(10,200); // default is 0,0 (top left corner)
        // Window Listeners
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          } //windowClosing
        }); //addWindowLister
        // Add Panels
        Container contentPane = getContentPane();
        contentPane.add(new testing());
      } //constructor MyFrame
    } //class MyFrame
import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    /*************************************************************
         *  TextPanel Class (with main method)
     *************************************************************/
    class testing extends JPanel {
        public testing() {
            JButton btnTesting = new JButton("Testing 2");
            btnTesting.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                }
            });
            add(btnTesting);
        }
      // override the paintComponent method
      // THE MAIN DEMO OF THIS EXAMPLE:
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Font f = new Font("SansSerif", Font.BOLD, 14);
        Font fi = new Font("SansSerif", Font.BOLD + Font.ITALIC, 14);
        FontMetrics fm = g.getFontMetrics(f);
        FontMetrics fim = g.getFontMetrics(fi);
        int cx = 75; int cy = 100;
        g.setFont(f);
        g.drawString("Hello, ", cx, cy);
        cx += fm.stringWidth("Hello, ");
        g.setFont(fi);
        g.drawString("World!", cx, cy);
      } //paintComponent
      //=============================================
      ///////////// main ////////////////////////////
      public static void main(String[] args) {
        JFrame f = new MyFrame("My Hello World Frame");
        f.show();
      } //main
    } //class TextPanel
    /*************************************************************
            MyFrame Class
     *************************************************************/
    class MyFrame extends JFrame {
      public MyFrame(String s) {
        // Frame Parameters
        setTitle(s);
        setSize(300,200); // default size is 0,0
        setLocation(10,200); // default is 0,0 (top left corner)
        System.err.println("Here");
        testing2 test = new testing2();
        test.setVisible(true);
        // Window Listeners
        addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          } //windowClosing
        }); //addWindowLister
        // Add Panels
        Container contentPane = getContentPane();
        contentPane.add(new testing());
      } //constructor MyFrame
    } //class MyFrame
 
    