How can I write the program
I would like to know how can i Change the program so that the Message'What is the sum of X and Y' can be shown in a GUI after I click the Start Button.
The program is shown below. Please help me,Thank You Very Much!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class client2 {
public static void main(String[] args){
Frame f = new ClientFrame("Client");
f.setSize(400,400);
f.setVisible(true);
}
}
class ClientFrame extends JFrame{
JPanel StartPanel = new JPanel();
JPanel OutputPanel = new JPanel();
String Question;
JLabel label=new JLabel(Question);
Button GameStart = new Button("Start the Game");
Container c=this.getContentPane();
public ClientFrame(String title){
super (title);
c.setLayout (new BorderLayout());
StartPanel.add(GameStart);
OutputPanel.add(label);
c.add(StartPanel,BorderLayout.NORTH);
c.add(OutputPanel,BorderLayout.CENTER);
GameStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent Evt) {
GameStart.setEnabled(false);
Integer x=10;
Integer y=20;
Question ="What is the sum of "+x+ "and" +y;
System.out.println("Java rules!");
}
});
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
}
}

