<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import javax.swing.*;

/** Answers to self-help exercises on writing your
    own subclass of JFrame. */
public class JFrameFun extends JFrame {
    
    /** Swap the width and height of this window. */
    public void SwapHtAndWidth() {
        setSize(getHeight(), getWidth());
    }
    
    /** Double the width of this window. */
    public void doubleWidth() {
        setSize(2*getWidth(), getHeight());
    }
    
    /** Halve the width of this window. */
    public void halveWidth() {
        setSize(getWidth() / 2, getHeight());
    }

    /** Set the title of the window to the Date and time. */
    public void setTitleToDate() {
        setTitle((new java.util.Date()).toString());
    }
    
    /** Put the position in the title. */
    public void putPositionInTitle() {
        setTitle("window is at (" + getX() + ", " + getY() + ")");
    }
    
    /** Switch the position and size of the window */
    public void swap() {
        int w= getWidth();
        int h= getHeight();
        int x= getX();
        int y= getY();
        setSize(x, y);
        setLocation(w, h);
    }
}</pre></body></html>