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
A technician has been told that a keyboard is not responding at all. What can the technician do quickly to determine whether tha
givi [52]

Answer:

Press Caps Lock key to see the light illuminates or not

Explanation:

Computer keyboard is the typewriter-style device that uses arrangement of the buttons or the keys to act as the mechanical levers or the electronic switches.

Keyboard keys  have characters which are engraved or printed on the surface and press of each key corresponds to the single written symbol.

If the keyboard is not working and to see whether it is working or not, there is a Caps Lock key on the keyboard. Generally, all keyboards have a Caps Lock light which will light up if the button is on. So, this can be a quick check.

6 0
4 years ago
The ____ feature automatically locates specific text and then replaces it with desired text. Find and Replace Locator Locate and
jekas [21]
The "Find and Replace" feature automatically locates specific text and then replaces it with desired text.
8 0
4 years ago
For every $1 of deposits, the banks can increase ________________ by the value of the Money Multiplier.
Snowcat [4.5K]
<span>A. Aggregate Price Level</span>
8 0
3 years ago
What are the constraints of mine shaft head gear​
Serhud [2]

Answer:

Mine headgear constructions support wheel mechanisms for suspending winding cables that transport workers and ore up and down deep level shafts. These strange anthropomorphic structures have become the iconic symbol for mining.

4 0
3 years ago
Anyone have Y.O.U.T.U.B.E or S.O.U.N.D.C.L.O.U.D. I need help putting my music and videos out there
kiruha [24]

Answer:

I do have Y.O.U.T.U.B.E.

Explanation:

1. Go on Y.O.U.T.U.B.E app.

2. Create account or log in to an existing account.

3. In the welcome screen, click the button of a camera on the top right corner next to your photo icon.

4. Click "Upload Video"

5. Then upload your video.

6. Add a description and details

7. Done! Just upload to on Y.O.U.T.U.B.E.

I hope this helps! Thank you:)

5 0
4 years ago
Other questions:
  • Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 3
    15·1 answer
  • What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? Group of answer choices
    10·1 answer
  • The ___________ process transforms new memories from a fragile state, in which they can be disrupted, to a more permanent state,
    10·1 answer
  • Which is an example of an active visual interface? a display indicating the amount of ammunition for the currently equipped weap
    13·2 answers
  • In what software development model does activity progress in a lock-step sequential process where no phase begins until the prev
    7·1 answer
  • Which approach to knowledge management capitalizes on tacit knowledge and requires heavy IT investment?
    8·1 answer
  • What is the difference between the Internet and the World Wide Web? Explain in your own words.
    13·2 answers
  • True or false Encryption prevents hackers from hacking data?
    8·1 answer
  • Can any one help me please with my computer science hwk :)
    11·1 answer
  • Where do animators work?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!