Create Roll Application Implements Gui Shown Figure 1 Default Images Must Set Shown Figure Q37217375

Create a Roll application that implements the GUIshown in figure 1 (default images
must be set as shown in figure 1). When the user clicks the Rollbutton, the program
must roll the dice, change the figures randomly, calculate the sumof the dice and
show it in a label (as shown in figure 2).


Answer


DiceGUI.java

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class DiceGUI extends JFrame implements ActionListener
{
JLabel l1;
JButton b1;
int x=1,y=1;
DiceGUI(String s) // constructor
{
super(); // calls super class constructor
setSize(500,500); // setting size of frame
setLayout(null);
this.setBackground(Color.WHITE); // setting backgroung color towhite
l1=new JLabel(“”); // creates JLabel oject
b1=new JButton(“Roll Dice”); // creates JButton object
l1.setBounds(100,50,200,30); // setting bounds to JLabel
add(l1);

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.