I've got a problem with changing JPanels color from another class. I'm trying to change it by clicking a button. I am creating an application where user can pick a colour theme what he wants.
First class:
public class First extends JFrame {
    public JPanel contentPane = new JPanel();
    public JPanel panel = new JPanel();
    public First() {
        JButton btnNewButton = new JButton("New button");
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                Second s = new Second();
                s.startSecond();
            }
        });
    }
 }
Second class:
public class Second extends JFrame {
    First f;
    private JPanel contentPane;
    public static void startSecond() {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Second sframe = new faijaso();
                    sframe.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    public Second() {   
        JButton btnNewButton = new JButton("New button");
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                f.panel.setBackground(Color.red);
                f.panel.repaint();
                f.panel.revalidate();
            }
        });
    }
}
 
    