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
How to install specific version of create-react-app so.
marusya05 [52]

Answer:

First, go to the package.json file and change the version of react, react-dom, and react-scripts to the desired version.

Next, clear the node_modules and the package-lock.json file.

Finally, hit:

npm install

8 0
2 years ago
A(n) monitoring vulnerability scanner is one that listens in on the network and determines vulnerable versions of both server an
Tom [10]

Answer: Passive

Explanation: Passive scanning is the process that scans the possibility of the risk that can arise while data is received starting port to the destination. It does the scanning between the server and the client software to define vulnerability .

It cannot work in those network which don't persist the traffic.No false data that is present in the application is detected by it if the data is unclear.

5 0
3 years ago
Encapsulation is a form of information hiding and an important characteristic of object-oriented programming. When a programmer
Ostrovityanka [42]
<h2>Answer:</h2>

There are a whole lot of encapsulation or information hiding examples in the Bible. Here are about 3 of them:

i. <em>The parables of Jesus</em>. Many times Jesus spoke in parables to teach His disciples and until He's explained they would not get the meaning.

ii. <em>The interpretation of dreams by Joseph</em>. A noticeable example is the one of the baker and the butler in Genesis 40. Each of them - the butler and the baker - both had a dream but the actual meaning and interpretation of those dreams were not known by them.

iii. <em>Peter walking on water</em> is yet another example of encapsulation. He was only following the instruction of the master. How he was able to walk on water was a mystery to him. Only Christ the master knew how. Encapsulation.

3 0
3 years ago
Norman Bates has a very unusual hobby what is it?
Allushta [10]

Answer:

<h3>Norman only likes to stuff birds, not other animals.</h3>
8 0
4 years ago
How can social media be used to find out about activities?
ICE Princess25 [194]
Hello RandomHacker


Using social media can inform you when events are happening near by. 

For example: Your favorite singer of band is going on tour and they are doing it near you, social media advertises this and you can find out in time to go.

Hope this helps
-Chris

3 0
3 years ago
Read 2 more answers
Other questions:
  • Define the term Frame Rate.
    12·1 answer
  • What is a PowerPoint template?
    6·2 answers
  • You will extend zyLab3, by adding a Player class and extending the PokemonField class. You will be working with three.java files
    13·1 answer
  • Passwords are usually alphanumeric and usually cannot contain spaces or ________.
    10·2 answers
  • The ____ object can trigger a selectedindexchanged event when a selection is made
    5·1 answer
  • All the read/write heads a hard disk are controlled by a(n) ____ which moves the read/write heads across the disk surfaces in un
    13·1 answer
  • design a relational database in EER for bike helmets and their reviews. a bike helmet has a name and color attributes. a bike co
    12·1 answer
  • How long does it take to send a 19 MiB file from Host A to Host B over a circuit-switched network, assuming:
    14·1 answer
  • bro i got banned for posting an amazing bulk pic, but this dude literally posted an inappropriate, dafuq is wrong with this bann
    8·2 answers
  • Which of the following correctly calculates the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!