Ask Question
14 April, 08:23

The 'client area' of a window is the area used to display the contents of the window (thus a title bar or border would lie outside the client area). For the Window class, the client area is nothing more than the entire window, and thus the height of the client area is nothing more than the value of the height instance variable.

Assume the existence of a Window class with existing methods, getWidth and getHeight. There is also a Window subclass, named TitledWindow that has an integer instance variable barHeight, containing the height of the title bar.

Write the method getClientAreaHeight for the TitledWindow class that returns the height (an integer) of the client area of a window with a title bar.

+3
Answers (1)
  1. 14 April, 08:30
    0
    The Java code is given below

    Explanation:

    Window. java:

    public class Window {

    private int width, height;

    public Window (int width, int height) {

    this. width = width;

    this. height = height;

    }

    public int getHeight () {

    return height;

    }

    public void setHeight (int height) {

    this. height = height;

    }

    public int getWidth () {

    return width;

    }

    public void setWidth (int width) {

    this. width = width;

    }

    @Override

    public String toString () {

    return "Window [width=" + width + ", height=" + height + "]";

    }

    }

    TitledWindow. java:

    public class TitledWindow extends Window {

    private int barHeight;

    public TitledWindow (int width, int height, int barHeight) {

    super (width, height);

    this. barHeight = barHeight;

    }

    public int getClientAreaHeight () {

    return barHeight + super. getHeight ();

    }

    @Override

    public String toString () {

    return "TitledWindow [width=" + super. getWidth () + ", height=" + super. getHeight () + ", barHeight=" + barHeight + "]";

    }

    }

    TestWindows. java:

    public class TestWindows {

    public static void main (String args[]) {

    Window w = new Window (450, 200);

    System. out. println ("Window: " + w);

    TitledWindow titledWindow = new TitledWindow (450, 200, 30);

    System. out. println ("titaledWindow: " + titledWindow);

    System. out. println ("titledWindow. height: " + titledWindow. getClientAreaHeight ());

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “The 'client area' of a window is the area used to display the contents of the window (thus a title bar or border would lie outside the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers