Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在JavaGWT中,如何将框架中加载的元素居中?_Java_Eclipse_Gwt - Fatal编程技术网

在JavaGWT中,如何将框架中加载的元素居中?

在JavaGWT中,如何将框架中加载的元素居中?,java,eclipse,gwt,Java,Eclipse,Gwt,我使用frame.setUrl(PATH)加载了一个html 它工作正常,但我想水平居中显示,框架对象上没有类似于面板小部件的.setHorizontalAlignment的方法 如何在GWT帧中居中元素 我将Eclipse用作带有GWT插件的IDE 编辑:我正在使用com.google.gwt.user.client.ui.Frame 只需将iframe括在一个div内,该div居中对齐。 试试这个 public void onModuleLoad() { // Make a new

我使用
frame.setUrl(PATH)加载了一个html

它工作正常,但我想水平居中显示,框架对象上没有类似于面板小部件的
.setHorizontalAlignment
的方法

如何在
GWT帧中居中元素

我将Eclipse用作带有
GWT插件的IDE


编辑:我正在使用com.google.gwt.user.client.ui.Frame

只需将
iframe
括在一个
div
内,该div
居中对齐。

试试这个

public void onModuleLoad() {

    // Make a new frame, and point it at Google.
    Frame frame = new Frame("http://www.google.com/");

    // Add it to the root panel.
    RootPanel.get("container").add(frame);

}
JSP/HTML:

...
<body> 
      <div id="container" align="center"></div>
</body>
...

显示一些代码。你在说什么框架?@Braj我正在使用com.google.gwt.user.client.ui.frame;我已经贴出了答案。请看一看。@Braj谢谢,原来我只需要把这些元素放在里面,谢谢!和
RootPanel.get(“容器”)
在入口点类中。
// Make a new frame, and point it at Google.
Frame frame = new Frame("http://www.google.com/");

DivElement div = Document.get().createDivElement();
div.setAttribute("align", "center");

div.appendChild(frame.getElement());

// Add it to the root panel.
RootPanel.get().getElement().appendChild(div);