在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);