使用 DJ Native Swing API 浏览器...如何在网页和网页中显示特定位置如何关闭浏览器的滚动条?

发布于 2024-11-19 14:31:32 字数 368 浏览 7 评论 0原文

好吧,这就是我的问题: 我做了一个 JPanel 来打开网页,但它接缝 它没有像我想要的那样工作,所以我正在寻找一种方法来使 DJ NATIVE SWING-SWT API JWebBrowser 仅打开网站上的特定位置 我关闭垂直或水平滚动条... 那么可以这样做吗? 需要您的帮助,请回答。 附: 我尝试了这些方法来关闭滚动:

JwebBrowser.setBarsVisible(false);
JwebBrowser.setButtonBarVisible(false);
JwebBrowser.setLocationBarVisible(false);

但我认为它们与滚动无关......

ok that's my problem :
i made a JPanel to open web pages but it seams
that it's not working like i want so im looking for a way to make the
DJ NATIVE SWING-SWT API JWebBrowser open a specific location on web site only
and i turn off the scroll bars vertical or horziontal...
so is it possible to do this?
need your help, please answer.
P.S :
i tried these methods to turn off scrolling:

JwebBrowser.setBarsVisible(false);
JwebBrowser.setButtonBarVisible(false);
JwebBrowser.setLocationBarVisible(false);

but i think they have nothing to do with scrolling....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷→糖丶微凉 2024-11-26 14:31:32

滚动条是本机组件的一部分。事实上,如果您有框架集或文本组件,同一页面中可能会有很多滚动条。

隐藏滚动条的一种方法是,我认为在加载目标页面后注入 JavaScript 即可完成此任务。

Scroll bars are part of the native component. In fact, if you have frame sets or text components, there can be lots of scroll bars in the same page.

One way of hiding scroll bars is I think to inject Javascript once the target page is loaded that would do this task.

苍风燃霜 2024-11-26 14:31:32

我相信这就是克里斯托弗的意思。这类似于我用来确保渲染的本机组件处于其最大尺寸的代码。我发现的 +20 足以克服任何不一致之处。

    String js_getHeight = 
    "var D = document;"+
    "return Math.max("+
    "    Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),"+
    "    Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),"+
    "    Math.max(D.body.clientHeight, D.documentElement.clientHeight)"+
    ");";
String js_getWidth = 
    "var D = document;"+
    "return Math.max("+
    "    Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),"+
    "    Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),"+
    "    Math.max(D.body.clientWidth, D.documentElement.clientWidth)"+
    ");";
webBrowser = new JWebBrowser();
webBrowser.addWebBrowserListener(new WebBrowserAdapter(){
      @Override public void loadingProgressChanged(WebBrowserEvent e) {
             if(e.getWebBrowser().getLoadingProgress()==100){
                      NativeComponent nComp = webBrowser.getNativeComponent();
                      double width = Double.parseDouble(webBrowser.executeJavascriptWithResult(js_getWidth).toString())+20;
                      double height = Double.parseDouble(webBrowser.executeJavascriptWithResult(js_getHeight).toString())+20;
                      nComp.setSize(new Dimension((int)width, (int)height));
             }
      }
});

I believe this is what Christopher was getting at. This is similar to the code I used to make sure the rendered native component was at its maximum size. The +20 I found was enough of a fudge to overcome any inconsistencies.

    String js_getHeight = 
    "var D = document;"+
    "return Math.max("+
    "    Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),"+
    "    Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),"+
    "    Math.max(D.body.clientHeight, D.documentElement.clientHeight)"+
    ");";
String js_getWidth = 
    "var D = document;"+
    "return Math.max("+
    "    Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),"+
    "    Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),"+
    "    Math.max(D.body.clientWidth, D.documentElement.clientWidth)"+
    ");";
webBrowser = new JWebBrowser();
webBrowser.addWebBrowserListener(new WebBrowserAdapter(){
      @Override public void loadingProgressChanged(WebBrowserEvent e) {
             if(e.getWebBrowser().getLoadingProgress()==100){
                      NativeComponent nComp = webBrowser.getNativeComponent();
                      double width = Double.parseDouble(webBrowser.executeJavascriptWithResult(js_getWidth).toString())+20;
                      double height = Double.parseDouble(webBrowser.executeJavascriptWithResult(js_getHeight).toString())+20;
                      nComp.setSize(new Dimension((int)width, (int)height));
             }
      }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文