1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
musickatia [10]
3 years ago
14

Design a GUI program as follows: The program will open up a window that contains a read-only text box and 2 buttons. One button

should say "I feel lucky! :)" on it and the other button should say "I don't feel lucky :( ". (Because why not, I actually used the emojis, but you don't have to) When the user clicks the "I feel lucky" button, the background color should change from white to something else (you can choose, I chose magenta), and the text box should say "You're lucky!" When the user clicks the "I don't feel lucky" button, the background color should become white again (or it should stay white if it was already) and the text box should become blank.

Computers and Technology
1 answer:
Marizza181 [45]3 years ago
6 0

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't accept the symbol

Explanation:

A graphical user interface (GUI) allows a user to interact with a computer program using a pointing device that manipulates small pictures on a computer screen. The small pictures are called icons or widgets. Various types of pointing devices can be used, such as a mouse, a stylus pen, or a human finger on a touch screen

import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JTextField;

public class LuckyButtons {

  static JFrame frame = new JFrame("Lucky Buttons");

  static JPanel panel = new JPanel();

  public static void main(String s[]) {

      panel.setLayout(null);

      final JTextField txt1 = new JTextField(10);

      txt1.setBounds(200, 50, 100, 30);

      // password field

      final JTextField txt2 = new JTextField(10);

      txt2.setBounds(320, 50, 100, 30);

      txt1.setEnabled(false);

      txt2.setEnabled(false);

      JButton btn1 = new JButton();

      btn1.setText("I feel lucky! :)");

      btn1.setBounds(200, 150, 130, 20);

      JButton btn2 = new JButton();

      btn2.setText("I don't feel lucky :(");

      btn2.setBounds(350, 150, 150, 20);

      btn1.addActionListener(new ActionListener() {

           "at"Override

          public void actionPerformed(ActionEvent aE) {

                  txt1.setText("I feel lucky! :)");

                  txt2.setText("I feel lucky! :)");

                  panel.setBackground(Color.red);

          }

      });

      btn2.addActionListener(new ActionListener() {

          "at"Override

          public void actionPerformed(ActionEvent aE) {

              txt1.setText("I don't feel lucky :(");

              txt2.setText("I don't feel lucky :(");

              panel.setBackground(Color.white);

          }

      });

      panel.add(txt1);

      panel.add(txt2);

      panel.add(btn1);

      panel.add(btn2);

     

      frame.add(panel);

      frame.setSize(600, 300);

      frame.setLocationRelativeTo(null);

      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      frame.setVisible(true);

  }

}

Kindly check the attached image below for the code output.

You might be interested in
In javascript, what can I put after player. to make my character go in the center of the screen? like example:
melamori03 [73]

Answer:

0,0

Explanation:

you could try to use the x-axis and y-axis to put your character in a certain place. I'm not totally sure if that is how javascript works, but for the x-axis and y-axis, the center is always(0,0).

6 0
3 years ago
WILL MARK BRAINLIEST.....
slamgirl [31]

Answer:

Variables. A variable is a way of naming and storing a value for later use by the program, ... its type, and optionally, setting an initial value (initializing the variable). ... byte x; x = 0; x = x - 1; // x now contains 255 - rolls over in neg. direction

Explanation:

7 0
3 years ago
The letters LAN stand for Area Network.
Slav-nsk [51]

The letter LAN stand for : Local Area Network

8 0
2 years ago
Read 2 more answers
Hey anyone wanna zoom.
Shalnov [3]

Sure, but I won't unmute or turn on camara. What's the code?

5 0
2 years ago
Read 2 more answers
Type you all suck if you want to be my freind
Nina [5.8K]

Answer:

you all suck

Explanation:

;)

4 0
3 years ago
Read 2 more answers
Other questions:
  • What device brocasts all data packets to other nodes on a network?
    5·1 answer
  • How Java provides protection through stack inspection approach ?
    7·1 answer
  • The Sumif formula will add numbers together from a range of numbers ONLY IF they contain the criteria. True or false
    8·1 answer
  • ​_____ was the first commercially successful computer. ​z3 ​eniac ​univac ​colossus
    13·1 answer
  • A number of related records that are treated as a unit is called
    6·1 answer
  • Which TranscribeMe tag should you use if you are unable to make out a word or phrase due to a difficult accent, poor audio, or a
    6·1 answer
  • Python3
    7·1 answer
  • Based on the code you created in this Unit, propose a way to re-use most of the code (with different information in the variable
    14·1 answer
  • Find the basic period and basic frequency of the function g(t)=8cos(10πt)+sin(15πt)
    9·1 answer
  • When comparison shopping, all of these hint at a good deal EXCEPT_____________________.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!