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
Give 5 comparisons of the three employees with the highest net pay
Anna71 [15]

Answer:

this is wot u get for not paying attiention on class

Explanation:

3 0
2 years ago
Read 2 more answers
Your school has been declared a school of technology
Angelina_Jolie [31]
I don't really understand the meaning of the question. Can you reply and i'll try to help...
7 0
3 years ago
What are the five layers in the internet protocol stack? What are the principal responsibilities of each of these lay?
mariarad [96]

Solution:

The five Layers in Internet protocol stack are:

1.Application Layer  

2.Transport Layer  

3.Network Layer  

4.Link Layer  

5.Physical Layer  

The principal responsibilities of these layers are as follows:

1.Application Layer •Applications with appropriate requirement for user.  

•It is reserved for network applications and their application protocols such as HTTP, SMTP, and FTP etc.  

•Its protocol uses transport layer protocols for establishing host-to-host connection.  

2.Transport Layer  

•It is responsible for End-to-Communication  

•Transport layer transports messages from application layer between client and server of application  

•It uses two protocol for transporting messages: TCP and UDP.TCP provides reliable connection oriented services, while UDP provides connectionless service  

3.Network Layer  

•Network Layer moves packets from one host to destination.

•It has two principal component:IP protocol:-It defines the datagrams and decide how the end system and router will work Routing protocols: these protocols decide the routing path between source and destination. 4.Link Layer  

•It is responsible for link-level communication  

•Link layer receives the data gram from network layer at each node and delivers it to next node, the next node passes the datagram to network layer.so This layer moves entire frames from one network element to adjacent one.

•The service provided by link layer is protocol dependent

5.Physical Layer  

•It provides Physical media

•At each node, it moves individual bits of frames to next node.  


7 0
2 years ago
How to work a computer cause i don't know how to
VladimirAG [237]

Answer:

power on, connect to internet, download games

6 0
3 years ago
Formulas should follow the___
tatuchka [14]

Answer:

Order of operations

Explanation:

4 0
2 years ago
Other questions:
  • Sarah maintains a blog about her soap-making business, and she has hired someone to create a database for this business. She mak
    6·1 answer
  • The World Wide Web consists of interconnected computer networks throughout the world that everyone can use. True or False
    13·2 answers
  • A tool that is used to search for and gather data from a page on the internet is called a ?
    11·2 answers
  • which student organization helps students with career development by having them become interms to sponsor conferences?
    9·1 answer
  • The ____________________ packet-filtering firewall allows only a particular packet with a particular source, destination, and po
    10·1 answer
  • Write a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in
    5·1 answer
  • A token is combination of hardware and software that acts as a gatekeeper and prevents unauthorized users from accessing private
    11·1 answer
  • Write a function that accepts an integer parameter and returns its integer square root (if it exists). The function should throw
    12·2 answers
  • HELP AASAP BRAINLIEST JUST HELP
    13·1 answer
  • Please help me on this please i am giving all of my points so please help me
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!