using java   Create a game menu with a image and below the image we have two clickable buttons (play game and instructions) when play game is clicked it proceeds to my trivia game   Here is part of my java code for the trivia game (If you are looking for the full go on YouTube and search bro code java quiz game the full code should be in the comments section   import java.awt.event.*; import java.awt.*; import javax.swing.*;   public class Quiz implements ActionListener {       String[] questions = {       "Factor the equation (X+3)(X+1)?",       "Which company created Java?",                        };       String[][] options = {       { "It cannot be factored", "X^2+4x+3", "2x^2+4x+3", " I don't know" },       { "Sun Microsystems", "Starbucks", "Microsoft", "Alphabet" },        char[] answers = {       'B',       'A',           };     char guess;   char answer;   int index;   int correct_guesses = 0;   int total_questions = questions.length;   int result;   int seconds = 10;       JFrame frame = new JFrame();     JTextField textfield = new JTextField();   JTextArea textarea = new JTextArea();   JButton buttonA = new JButton();   JButton buttonB = new JButton();   JButton buttonC = new JButton();   JButton buttonD = new JButton();   JLabel answer_labelA = new JLabel();   JLabel answer_labelB = new JLabel();   JLabel answer_labelC = new JLabel();   JLabel answer_labelD = new JLabel();   JLabel time_label = new JLabel();   JLabel seconds_left = new JLabel();   JTextField number_right = new JTextField();   JTextField percentage = new JTextField();     Timer timer = new Timer(1000, new ActionListener() {         @Override     public void actionPerformed(ActionEvent e) {       seconds--;       seconds_left.setText(String.valueOf(seconds));       if (seconds <= 0) {         displayAnswer();       }     }   });       public Quiz() {         frame.setTitle("Quiz Time");     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     frame.setSize(650, 650);     frame.getContentPane().setBackground(new Color(50, 50, 50));     frame.setLayout(null);     frame.setResizable(false);          textfield.setBounds(0, 0, 650, 50);     textfield.setBackground(new Color(25, 25, 25));     textfield.setForeground(new Color(25, 255, 0));     textfield.setFont(new Font("Ink Free", Font.BOLD, 30));     textfield.setBorder(BorderFactory.createBevelBorder(1));     textfield.setHorizontalAlignment(JTextField.CENTER);     textfield.setEditable(false);         textarea.setBounds(0, 50, 650, 50);     textarea.setLineWrap(true);     textarea.setWrapStyleWord(true);     textarea.setBackground(new Color(25, 25, 25));     textarea.setForeground(new Color(25, 255, 0));     textarea.setFont(new Font("MV Boli", Font.BOLD, 25));     textarea.setBorder(BorderFactory.createBevelBorder(1));     textarea.setEditable(false);          buttonA.setBounds(0, 100, 100, 100);     buttonA.setFont(new Font("MV Boli", Font.BOLD, 35));     buttonA.setFocusable(false);     buttonA.addActionListener(this);     buttonA.setText("A");          buttonB.setBounds(0, 200, 100, 100);     buttonB.setFont(new Font("MV Boli", Font.BOLD, 35));     buttonB.setFocusable(false);     buttonB.addActionListener(this);     buttonB.setText("B");         buttonC.setBounds(0, 300, 100, 100);     buttonC.setFont(new Font("MV Boli", Font.BOLD, 35));     buttonC.setFocusable(false);     buttonC.addActionListener(this);     buttonC.setText("C");           buttonD.setBounds(0, 400, 100, 100);     buttonD.setFont(new Font("MV Boli", Font.BOLD, 35));     buttonD.setFocusable(false);     buttonD.addActionListener(this);     buttonD.setText("D");           answer_labelA.setBounds(125, 100, 500, 100);     answer_labelA.setBackground(new Color(50, 50, 50));     answer_labelA.setForeground(new Color(25, 255, 0));     answer_labelA.setFont(new Font("MV Boli", Font.PLAIN, 35));             answer_labelB.setBounds(125, 200, 500, 100);     answer_labelB.setBackground(new Color(50, 50, 50));     answer_labelB.setForeground(new Color(25, 255, 0));     answer_labelB.setFont(new Font("MV Boli", Font.PLAIN, 35));

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 3GZ
icon
Related questions
Question

using java

 

  1. Create a game menu with a image and below the image we have two clickable buttons (play game and instructions) when play game is clicked it proceeds to my trivia game

 

Here is part of my java code for the trivia game (If you are looking for the full go on YouTube and search bro code java quiz game the full code should be in the comments section

 

import java.awt.event.*;

import java.awt.*;

import javax.swing.*;

 

public class Quiz implements ActionListener {

 

 

  String[] questions = {

      "Factor the equation (X+3)(X+1)?",

      "Which company created Java?",

      

     

     

 

  };

 

 

  String[][] options = {

      { "It cannot be factored", "X^2+4x+3", "2x^2+4x+3", " I don't know" },

      { "Sun Microsystems", "Starbucks", "Microsoft", "Alphabet" },

    

  char[] answers = {

      'B',

      'A',

     

 

  };

 

  char guess;

  char answer;

  int index;

  int correct_guesses = 0;

  int total_questions = questions.length;

  int result;

  int seconds = 10;

 

 

  JFrame frame = new JFrame();

 

  JTextField textfield = new JTextField();

  JTextArea textarea = new JTextArea();

  JButton buttonA = new JButton();

  JButton buttonB = new JButton();

  JButton buttonC = new JButton();

  JButton buttonD = new JButton();

  JLabel answer_labelA = new JLabel();

  JLabel answer_labelB = new JLabel();

  JLabel answer_labelC = new JLabel();

  JLabel answer_labelD = new JLabel();

  JLabel time_label = new JLabel();

  JLabel seconds_left = new JLabel();

  JTextField number_right = new JTextField();

  JTextField percentage = new JTextField();

 

  Timer timer = new Timer(1000, new ActionListener() {

   

    @Override

    public void actionPerformed(ActionEvent e) {

      seconds--;

      seconds_left.setText(String.valueOf(seconds));

      if (seconds <= 0) {

        displayAnswer();

      }

    }

  });

 

 

  public Quiz() {

   

    frame.setTitle("Quiz Time");

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(650, 650);

    frame.getContentPane().setBackground(new Color(50, 50, 50));

    frame.setLayout(null);

    frame.setResizable(false);

 

  

    textfield.setBounds(0, 0, 650, 50);

    textfield.setBackground(new Color(25, 25, 25));

    textfield.setForeground(new Color(25, 255, 0));

    textfield.setFont(new Font("Ink Free", Font.BOLD, 30));

    textfield.setBorder(BorderFactory.createBevelBorder(1));

    textfield.setHorizontalAlignment(JTextField.CENTER);

    textfield.setEditable(false);

 

 

    textarea.setBounds(0, 50, 650, 50);

    textarea.setLineWrap(true);

    textarea.setWrapStyleWord(true);

    textarea.setBackground(new Color(25, 25, 25));

    textarea.setForeground(new Color(25, 255, 0));

    textarea.setFont(new Font("MV Boli", Font.BOLD, 25));

    textarea.setBorder(BorderFactory.createBevelBorder(1));

    textarea.setEditable(false);

 

  

    buttonA.setBounds(0, 100, 100, 100);

    buttonA.setFont(new Font("MV Boli", Font.BOLD, 35));

    buttonA.setFocusable(false);

    buttonA.addActionListener(this);

    buttonA.setText("A");

 

  

    buttonB.setBounds(0, 200, 100, 100);

    buttonB.setFont(new Font("MV Boli", Font.BOLD, 35));

    buttonB.setFocusable(false);

    buttonB.addActionListener(this);

    buttonB.setText("B");

 

 

    buttonC.setBounds(0, 300, 100, 100);

    buttonC.setFont(new Font("MV Boli", Font.BOLD, 35));

    buttonC.setFocusable(false);

    buttonC.addActionListener(this);

    buttonC.setText("C");

 

   

    buttonD.setBounds(0, 400, 100, 100);

    buttonD.setFont(new Font("MV Boli", Font.BOLD, 35));

    buttonD.setFocusable(false);

    buttonD.addActionListener(this);

    buttonD.setText("D");

 

   

    answer_labelA.setBounds(125, 100, 500, 100);

    answer_labelA.setBackground(new Color(50, 50, 50));

    answer_labelA.setForeground(new Color(25, 255, 0));

    answer_labelA.setFont(new Font("MV Boli", Font.PLAIN, 35));

 

   

 

    answer_labelB.setBounds(125, 200, 500, 100);

    answer_labelB.setBackground(new Color(50, 50, 50));

    answer_labelB.setForeground(new Color(25, 255, 0));

    answer_labelB.setFont(new Font("MV Boli", Font.PLAIN, 35));



   

   

Expert Solution
steps

Step by step

Solved in 6 steps with 7 images

Blurred answer
Knowledge Booster
Running Time of Application
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT