Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could someone please help me with what they are asking in Java language? I\'m lo

ID: 646084 • Letter: C

Question

Could someone please help me with what they are asking in Java language? I'm lost, I've read the chapter twice, and I still don't understand what they're asking.

Here is the Question. #3 and #4.

3. Use the documentation from the Java API documentation to research the methods of the JFrame class that are called by this code. Then, add comments to the code to indicate which class the method is inherited from.

4. Use your research from step 3 to determine which class inherited by the JFrame class declares the setVisible method. Then, import that class and modify the code in the main method so the frame variable is declared as that type rather than as a JFram type. Run the application to verify that it still works properly.

Here is the source code for this exersice:

import javax.swing.JFrame;

public class ProductFrame extends JFrame
{
    public ProductFrame()
    {
        // all of these methods are available because
        // they are inherited from the JFrame class
        // and its superclasses

        this.setTitle("Product");
        this.setSize(200, 200);
        this.setLocation(10, 10);
        this.setResizable(false);

        // this method uses a field that's available
        // because it's inherited
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args)
    {
        // this creates an instance of the ProductFrame
        JFrame frame = new ProductFrame();

        // this displays the frame
        frame.setVisible(true);
    }
}

Explanation / Answer

Ans 3 : In this question they are asking you to study about the JFrame class and determine in which line of code the jframe class is inherited and by which class.

In this source code the line " public class ProductFrame extends JFrame " states that the ProductFrame class Inherit the JFrame class.

Your answer to that question should be as follows

import javax.swing.JFrame;

public class ProductFrame extends JFrame                   // ProductFrame class Inherit the JFrame class.
{
    public ProductFrame()
    {
        // all of these methods are available because
        // they are inherited from the JFrame class
        // and its superclasses

        this.setTitle("Product");
        this.setSize(200, 200);
        this.setLocation(10, 10);
        this.setResizable(false);

        // this method uses a field that's available
        // because it's inherited
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args)
    {
        // this creates an instance of the ProductFrame
        JFrame frame = new ProductFrame();

        // this displays the frame
        frame.setVisible(true);
    }
}

Ans 4 : In this question they are asking you to study about the JFrame class and determine which class is inherited by the JFrame class so that the setV isible method can be used

Your answer to that question should be as follows

import javax.swing.*;

public class ProductFrame extends JFrame                   // ProductFrame class Inherit the JFrame class.
{

    JFrame frame;
    public ProductFrame()
    {
        // all of these methods are available because
        // they are inherited from the JFrame class
        // and its superclasses

        this.setTitle("Product");
        this.setSize(200, 200);
        this.setLocation(10, 10);
        this.setResizable(false);

        // this method uses a field that's available
        // because it's inherited
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

this.setVisible(true);
    }

    public static void main(String[] args)
    {
        // this creates an instance of the ProductFrame
        new ProductFrame();
    }
}

The answer is provided on the bases of my knowledge and information on the subject hope you had understood.

Thanks.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote