EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 14, Problem 2PE

a.

Explanation of Solution

Program:

File name: “JFrameDisableButton.java

//Import necessary header files

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

//Define a class named JFrameDisableButton

public class JFrameDisableButton extends JFrame implements ActionListener

{

    //Declare a variable and initialize the value

    final int SIZE = 180;

    //Retrieves the content pane layer

    Container con = getContentPane();

    //Create a JButton with the text "Press Me"

    JButton button = new JButton("Press Me");

    //Define a default constructor JFrameDisableButton

    public JFrameDisableButton()

    {

        //Set the title and layout to the frame

        super("Frame");

        con.setLayout(new FlowLayout());

        //Set the dimensions and visibility to the frame

        setSize(SIZE, SIZE);

        setVisible(true);

        //Add the button to the frame

        con...

b.

Explanation of Solution

Program:

File name: “JFrameDisableButton2.java

//Import necessary header files

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

//Define a class named JFrameDisableButton2

public class JFrameDisableButton2 extends JFrame implements ActionListener

{

    //Declare a variable and initialize the value

    final int SIZE = 180;

    //Retrieves the content pane layer

    Container con = getContentPane();

    //Create a JButton with the text "Press Me"

    JButton button = new JButton("Press Me");

    //Declare the variables and initialize the value

    int count = 0;

    final int MAX = 8;

    //Create a label with the text "That's enough!"

    JLabel label = new JLabel("That's enough!");

    //Define a default constructor JFrameDisableButton2

    public JFrameDisableButton2()

    {

        //Set the title and layout to the frame

        super("Frame");

        con.setLayout(new FlowLayout());

        //Set the dimensions and visibility to the frame

        setSize(SIZE, SIZE);

        setVisible(true);

        //Add the button to the frame

        con.add(button);

        //Add the label to the frame

        con...

Blurred answer
Students have asked these similar questions
Write an application that displays a JFrame containing the opening sentence from A Christmas Carol. Add a button to the frame in the JBookQuote program. When the user clicks the button, display the title of the book that contains the quote in the available JLabel using the setText() method. Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade. Once you are happy with your results, click the Submit button to record your score.
Create a JavaFX application with at least six labels that contain facts about your favorite topic—for example, the French Revolution or astronomy. Every time the user clicks a Button, remove one of the Labels and add a different one.
In Java, create a user interface that has a top bar that includes a menu. The menu should have four items. When the user selects the first menu option, then the date and time should be printed in a text box. When the user selects the second menu option, then the text box contents should be written to a text file named "log.txt." When the user selects the third menu item then the frame background color changes to random color hue of the color green. The menu option should display the initial random hue each time selected for a single execution of the program. See https://www.w3schools.com/colors/colors_picker.asp When the user selects the fourth menu option then the program exits. Thank you

Chapter 14 Solutions

EBK JAVA PROGRAMMING

Knowledge Booster
Background pattern image
Computer Science
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
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Time Complexity Analysis - How To Calculate Running Time | InterviewBit; Author: InterviewBit;https://www.youtube.com/watch?v=--oxG4Q1PA0;License: Standard YouTube License, CC-BY