home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.peer.FramePeer;
-
- public class Frame extends Window implements MenuContainer {
- public static final int DEFAULT_CURSOR = 0;
- public static final int CROSSHAIR_CURSOR = 1;
- public static final int TEXT_CURSOR = 2;
- public static final int WAIT_CURSOR = 3;
- public static final int SW_RESIZE_CURSOR = 4;
- public static final int SE_RESIZE_CURSOR = 5;
- public static final int NW_RESIZE_CURSOR = 6;
- public static final int NE_RESIZE_CURSOR = 7;
- public static final int N_RESIZE_CURSOR = 8;
- public static final int S_RESIZE_CURSOR = 9;
- public static final int W_RESIZE_CURSOR = 10;
- public static final int E_RESIZE_CURSOR = 11;
- public static final int HAND_CURSOR = 12;
- public static final int MOVE_CURSOR = 13;
- String title;
- Image icon;
- MenuBar menuBar;
- boolean resizable;
- Image cursorImage;
- int cursorType;
- Color cursorFg;
- Color cursorBg;
-
- public Frame() {
- this.title = "Untitled";
- this.resizable = true;
- super.visible = false;
- ((Container)this).setLayout(new BorderLayout());
- }
-
- public Frame(String title) {
- this();
- this.title = title;
- }
-
- public synchronized void addNotify() {
- super.peer = ((Window)this).getToolkit().createFrame(this);
- if (this.menuBar != null) {
- this.menuBar.addNotify();
- ((FramePeer)super.peer).setMenuBar(this.menuBar);
- }
-
- super.addNotify();
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- FramePeer peer = (FramePeer)super.peer;
- if (peer != null) {
- peer.setTitle(title);
- }
-
- }
-
- public Image getIconImage() {
- return this.icon;
- }
-
- public void setIconImage(Image image) {
- this.icon = image;
- FramePeer peer = (FramePeer)super.peer;
- if (peer != null) {
- peer.setIconImage(image);
- }
-
- }
-
- public MenuBar getMenuBar() {
- return this.menuBar;
- }
-
- public synchronized void setMenuBar(MenuBar mb) {
- if (this.menuBar != mb) {
- if (mb.parent != null) {
- mb.parent.remove(mb);
- }
-
- if (this.menuBar != null) {
- this.remove(this.menuBar);
- }
-
- this.menuBar = mb;
- this.menuBar.parent = this;
- FramePeer peer = (FramePeer)super.peer;
- if (peer != null) {
- this.menuBar.addNotify();
- peer.setMenuBar(this.menuBar);
- }
-
- }
- }
-
- public synchronized void remove(MenuComponent m) {
- if (m == this.menuBar) {
- FramePeer peer = (FramePeer)super.peer;
- if (peer != null) {
- this.menuBar.removeNotify();
- this.menuBar.parent = null;
- peer.setMenuBar((MenuBar)null);
- }
-
- this.menuBar = null;
- }
-
- }
-
- public synchronized void dispose() {
- if (this.menuBar != null) {
- this.remove(this.menuBar);
- this.menuBar = null;
- }
-
- super.dispose();
- }
-
- public boolean isResizable() {
- return this.resizable;
- }
-
- public void setResizable(boolean resizable) {
- this.resizable = resizable;
- FramePeer peer = (FramePeer)super.peer;
- if (peer != null) {
- peer.setResizable(resizable);
- }
-
- }
-
- public void setCursor(int cursorType) {
- if (cursorType >= 0 && cursorType <= 13) {
- this.cursorType = cursorType;
- if (super.peer != null) {
- ((FramePeer)super.peer).setCursor(cursorType);
- }
-
- } else {
- throw new IllegalArgumentException("illegal cursor type");
- }
- }
-
- public int getCursorType() {
- return this.cursorType;
- }
-
- protected String paramString() {
- String str = super.paramString();
- if (this.resizable) {
- str = str + ",resizable";
- }
-
- if (this.title != null) {
- str = str + ",title=" + this.title;
- }
-
- return str;
- }
- }
-