Java Rectangle Bounds exportBounds(Frame theFame, Document doc)

Here you can find the source of exportBounds(Frame theFame, Document doc)

Description

Extracts the bounds information from a given Frame and returns the XML representation thereof.

License

Apache License

Parameter

Parameter Description
theFame The target frame.
doc The XML document from which the XML element is to be constructed.

Return

The XML construct representing the bounds information from the given frame.

Declaration

public static Element exportBounds(Frame theFame, Document doc) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.*;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    /**//from  www  .j a v  a2  s. c  o m
     * Extracts the bounds information from a given Frame and returns the XML
     * representation thereof. Must be invoked from the EDT.
     *
     * @param theFame The target frame.
     * @param doc The XML document from which the XML element is to be
     * constructed.
     * @return The XML construct representing the bounds information from the
     * given frame.
     */
    public static Element exportBounds(Frame theFame, Document doc) {
        Element ret = doc.createElement("Bounds");
        ret.setAttribute("Maximized", String.valueOf(((theFame.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0)));
        Rectangle bounds = theFame.getBounds();
        ret.setAttribute("X", String.valueOf((int) bounds.getX()));
        ret.setAttribute("Y", String.valueOf((int) bounds.getY()));
        ret.setAttribute("Width", String.valueOf((int) bounds.getWidth()));
        ret.setAttribute("Height", String.valueOf((int) bounds.getHeight()));
        return ret;
    }
}

Related

  1. encodeBounds(Rectangle rBounds)
  2. getBounds(Shape s)
  3. getBoundsInAncestor(Container ancestor, final Component comp, Rectangle bounds)
  4. getCenteredBoundsOn(Rectangle srcBounds, int width, int height)
  5. getLocalBounds(Component aComponent)