001 /*
002 * Copyright 2006 Google Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package com.google.gwt.user.client.ui;
017
018 import com.google.gwt.user.client.DOM;
019
020 /**
021 * An widget that wraps an IFRAME element, which can contain an arbitrary web
022 * site.
023 *
024 * <p>Note that if you are using {@link com.google.gwt.user.client.History}, any
025 * browser history items generated by the Frame will interleave with your
026 * application's history.</p>
027 *
028 * <h3>CSS Style Rules</h3>
029 * <ul class='css'>
030 * <li>.gwt-Frame { }</li>
031 * </ul>
032 *
033 * <h3>Example</h3>
034 * {@link com.google.gwt.examples.FrameExample code}
035 */
036 public class Frame extends FocusWidget {
037
038 /**
039 * Creates an empty frame.
040 */
041 public Frame() {
042 super(DOM.createIFrame());
043 }
044
045 /**
046 * Creates a frame that displays the resource at the specified URL.
047 *
048 * @param url the URL of the resource to be displayed
049 */
050 public Frame(String url) {
051 this();
052 setUrl(url);
053 }
054
055 /**
056 * Gets the URL of the frame's resource.
057 *
058 * @return the frame's URL
059 */
060 public String getUrl() {
061 return DOM.getAttribute(getElement(), "src");
062 }
063
064 /**
065 * Sets the URL of the resource to be displayed within the frame.
066 *
067 * @param url the frame's new URL
068 */
069 public void setUrl(String url) {
070 DOM.setAttribute(getElement(), "src", url);
071 }
072 }