Asked by anonymous

Object[] options1 = { "Try This Number", "Choose A Random Number","Quit" };

JPanel panel = new JPanel();
panel.add(new JLabel("Enter number between 0 and 1000"));
JTextField textField = new JTextField(10);
panel.add(textField);

int result = JOptionPane.showOptionDialog(null, panel, "Enter a Number",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,null, options1, null);
if (result == JOptionPane.YES_OPTION){
JOptionPane.showMessageDialog(null, textField.getText());
}

the question is
how do I put an if statement for "Try This Number", "Choose A Random Number","Quit"

Answers

Answered by oobleck
google "java random number" and you will find many code snippets dealing with random numbers. The java documentation is also excellent. Search it.

Related Questions