public final class HostServices extends Object
| 修飾子と型 | メソッドと説明 |
|---|---|
String |
getCodeBase()
このアプリケーションのコード・ベースURIを取得します。
|
String |
getDocumentBase()
このアプリケーションのドキュメント・ベースURIを取得します。
|
JSObject |
getWebContext()
このアプリケーションを含むWebページの包含DOMウィンドウのJavaScriptハンドルを返します。
|
String |
resolveURI(String base, String rel)
指定した相対URIをベースURIに対して解決し、解決済のURIを返します。
|
void |
showDocument(String uri)
指定したURIを新しいブラウザ・ウィンドウまたはタブで開きます。
|
public final String getCodeBase()
public final String getDocumentBase()
public final String resolveURI(String base, String rel)
例:
HostServices services = getHostServices();
String myImage = services.resolveURI(services.getDocumentBase(),
"image.jpg");
Image image = new Image(myImage);
base - 相対URIを解決するために照合するベースURIrel - 解決対象の相対URINullPointerException - baseまたはrelのいずれかの文字列がnullの場合。IllegalArgumentException - baseまたはrelのいずれかのURI文字列の解析でエラーが発生した場合、またはURIの解決でその他のエラーがある場合。public final void showDocument(String uri)
uri - ブラウザで開かれるWebページのURI。public final JSObject getWebContext()
例:
JSObject jsWin = getHostServices().getWebContext();
if (jsWin != null) {
jsWin.eval("var b = document.body;" +
"var newdiv = document.createElement('div');" +
"newdiv.innerHTML = '<br>Hello from JavaScript!';" +
"b.appendChild(newdiv);");
}
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.