src/share/classes/sun/awt/LightweightFrame.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.Container;
  29 import java.awt.Frame;
  30 import java.awt.Graphics;
  31 import java.awt.Image;
  32 import java.awt.MenuBar;
  33 import java.awt.MenuComponent;

  34 import java.awt.Toolkit;
  35 import java.awt.peer.FramePeer;
  36 
  37 /**
  38  * The class provides basic functionality for a lightweight frame
  39  * implementation. A subclass is expected to provide painting to an
  40  * offscreen image and access to it. Thus it can be used for lightweight
  41  * embedding.
  42  *
  43  * @author Artem Ananiev
  44  * @author Anton Tarasov
  45  */
  46 @SuppressWarnings("serial")
  47 public abstract class LightweightFrame extends Frame {
  48 
  49     /**
  50      * Constructs a new, initially invisible {@code LightweightFrame}
  51      * instance.
  52      */
  53     public LightweightFrame() {


 107      */
 108     public void emulateActivation(boolean activate) {
 109         ((FramePeer)getPeer()).emulateActivation(activate);
 110     }
 111 
 112     /**
 113      * Delegates the focus grab action to the client (embedding) application.
 114      * The method is called by the AWT grab machinery.
 115      *
 116      * @see SunToolkit#grab(java.awt.Window)
 117      */
 118     public abstract void grabFocus();
 119 
 120     /**
 121      * Delegates the focus ungrab action to the client (embedding) application.
 122      * The method is called by the AWT grab machinery.
 123      *
 124      * @see SunToolkit#ungrab(java.awt.Window)
 125      */
 126     public abstract void ungrabFocus();












































 127 }


  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.Container;
  29 import java.awt.Frame;
  30 import java.awt.Graphics;
  31 import java.awt.Image;
  32 import java.awt.MenuBar;
  33 import java.awt.MenuComponent;
  34 import java.awt.Rectangle;
  35 import java.awt.Toolkit;
  36 import java.awt.peer.FramePeer;
  37 
  38 /**
  39  * The class provides basic functionality for a lightweight frame
  40  * implementation. A subclass is expected to provide painting to an
  41  * offscreen image and access to it. Thus it can be used for lightweight
  42  * embedding.
  43  *
  44  * @author Artem Ananiev
  45  * @author Anton Tarasov
  46  */
  47 @SuppressWarnings("serial")
  48 public abstract class LightweightFrame extends Frame {
  49 
  50     /**
  51      * Constructs a new, initially invisible {@code LightweightFrame}
  52      * instance.
  53      */
  54     public LightweightFrame() {


 108      */
 109     public void emulateActivation(boolean activate) {
 110         ((FramePeer)getPeer()).emulateActivation(activate);
 111     }
 112 
 113     /**
 114      * Delegates the focus grab action to the client (embedding) application.
 115      * The method is called by the AWT grab machinery.
 116      *
 117      * @see SunToolkit#grab(java.awt.Window)
 118      */
 119     public abstract void grabFocus();
 120 
 121     /**
 122      * Delegates the focus ungrab action to the client (embedding) application.
 123      * The method is called by the AWT grab machinery.
 124      *
 125      * @see SunToolkit#ungrab(java.awt.Window)
 126      */
 127     public abstract void ungrabFocus();
 128 
 129     /**
 130      * Returns the scale factor of this frame. The default value is 1.
 131      *
 132      * @return the scale factor
 133      * @see #notifyDisplayChanged(int)
 134      */
 135     public abstract int getScaleFactor();
 136 
 137     /**
 138      * Called when display of the hosted frame is changed.
 139      *
 140      * @param scaleFactor the scale factor
 141      */
 142     public abstract void notifyDisplayChanged(int scaleFactor);
 143 
 144     /**
 145      * Host window absolute bounds.
 146      */
 147     private int hostX, hostY, hostW, hostH;
 148 
 149     /**
 150      * Returns the absolute bounds of the host (embedding) window.
 151      *
 152      * @return the host window bounds
 153      */
 154     public Rectangle getHostBounds() {
 155         if (hostX == 0 && hostY == 0 && hostW == 0 && hostH == 0) {
 156             // The client app is probably unaware of the setHostBounds.
 157             // A safe fall-back:
 158             return getBounds();
 159         }
 160         return new Rectangle(hostX, hostY, hostW, hostH);
 161     }
 162 
 163     /**
 164      * Sets the absolute bounds of the host (embedding) window.
 165      */
 166     public void setHostBounds(int x, int y, int w, int h) {
 167         hostX = x;
 168         hostY = y;
 169         hostW = w;
 170         hostH = h;
 171     }
 172 }