הנה:
זה למעלה:
public class Trivia extends JFrame implements ActionListener, WindowListener
וזה המתודות (לא יודע איזו מהן כרגע, אז אני שם את שתיהן כאן)
@Override
public void windowClosing(WindowEvent e)
{
System.out.println("bye");
// TODO Auto-generated method stub
if (grade>100)
{
grade=100;
JOptionPane.showMessageDialog(null,"Your grade is: "+grade);
}
else JOptionPane.showMessageDialog(null,"Your grade is: "+grade);
}
@Override
public void windowClosed(WindowEvent e)
{
System.out.println("hi");
// TODO Auto-generated method stub
if (grade>100)
{
grade=100;
JOptionPane.showMessageDialog(null,"Your grade is: "+grade);
}
else JOptionPane.showMessageDialog(null,"Your grade is: "+grade);
}
הדבר שאני מחפש: אם המשתמש לחץ על האיקס בצד שיקפוץ החלון עם ההודעה.