I want to add a timer button to my main frame but it is in another class and I don't know how to use it in my main class. I need a timer button in my frame but I can't make it without another class. In that class I can't call my main frame. This is my code:
class ButtonTimer extends Thread{
private JButton button = new JButton(" ");
private int count = 1;
public ButtonTimer() {
    Timer time = new Timer(1000, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            button.setText(String.valueOf(count));
            count++;
        }
    });
    time.start();
    JFrame frame1 = new JFrame();
    frame1.add(button);
    frame1.setBounds(0, 20, 100, 50);
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame1.pack();
    frame1.setVisible(true);
}
}
public class game {
public static void main(String[] args) {
    JFrame frame2 = new JFrame();
    frame2.setBounds(0, 0, 1000, 5000);
    frame2.setVisible(true);
    JLayeredPane jlp = new JLayeredPane();
    jlp.setBounds(0, 0, 1000, 500);
    frame2.add(jlp);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new ButtonTimer();
        }
    });
}
}
How can I do this?
 
     
     
    