Create a package called mathpractice Create a class with mai

Create a package called mathpractice

Create a class (with main) called MathPractice

The numbers should be randomly generated when you select the reset button.

Be sure to call the three images:

smiley.jpg

frown.jpg

Solution

package mathpractice;
public class MathPractice
{
...statement;
}


public class MathPractice extends JFrame implements ActionListener{
private static JFrame frame;
private static JPanel p;
private static JButton b;
private static JButton edit;
private static JLabel random;


public static void main(String[] args) {
MathPractice bl=newMathPractice();
bl.gui();


}
public void gui(){
frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 500);
frame.setLocation(500, 200);
frame.setTitle(\"random1\");


p= new JPanel();
p.setLayout(null);
p.setBackground(Color.GRAY);


b = new JButton(\"Start play\");
b.setBounds(450, 50, 200, 50);

b.addActionListener(this);

choose= new JButton(\"edit\");
choose.setBounds(100, 50, 200, 50);
choose.addActionListener(this);

random= new JLabel(\"\");
random.setBounds(200, 150, 200, 50);

  
//text.setText();
  
p.add(random);
p.add(b);
frame.add(p);
frame.setVisible(true);
}

public void actionPerformed(ActionEvent e){

if(e.getSource()== b){

p.add(edit);
b.setEnabled(false);
}
if(e.getSource()== choose){
int randomNumbers = (int )(Math.random() * 11 + 1);
random.setText(String.valueOf(random));
  
}
}ImageIcon smile= new ImageIcon(\"C:\\smile.jpeg);
Similarly
ImageIcon smile= new ImageIcon(\"C:\\frown.jpeg);

Create a package called mathpractice Create a class (with main) called MathPractice The numbers should be randomly generated when you select the reset button. B

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site