0
  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){  
  if (JOptionPane.showConfirmDialog(null, "PROCEED TO NEXT LEVEL?", "AWESOME!!! CORRECT ANSWER ---",
        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
    {
     String myCoin = coin.getText();
   int   points = Integer.parseInt(myCoin);


new hint().points2 = pointq1;
    new hint().setVisible(true);
    }

} This is the code of my first frame, and i have a value of my coin button in my first frame, so i am getting the value of my coin button and convert it to int and put the value in 'points' variable , hint() is my second frame and 'points2' is my variable in second frame. Now, I just want my points2 variable will be equal to he value of my coins button that is placed in variable 'points'.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

1 Answers1

0

Create/Update your class hint to have a variable in its constructor like so:

class Hint{
    private int points2;
    public Hint(int points2){
        this.points2 = points2;
    }
}

So, in your new implementations, it would be like:

String myCoin = coin.getText(); 
int points1 = Integer.parseInt(myCoin);
new Hint(points1).setVisible(true);
timclutton
  • 12,682
  • 3
  • 33
  • 43