简体   繁体   English

如何以编程方式打开新的浏览器窗口

[英]How to open a new browser window programmatically

I am trying to move from JavaFX2 to using directly the browser for the interface of my program.我正在尝试从 JavaFX2 转移到直接使用浏览器作为我的程序界面。 One requirement that I have is that, my program should open in a new browser window, not in a tab.我的一个要求是,我的程序应该在新的浏览器窗口中打开,而不是在选项卡中。

This is because I may launch many instance of the program which are independent program that communicate, and I want to visualize their interface all at once.这是因为我可能会启动许多程序实例,它们是相互通信的独立程序,我想一次将它们的界面全部可视化。

I do not want to have one window that show all of them, these are independent program that can be distributed and communicate with each other, provided that they have each other address.我不想有一个窗口显示所有这些,这些是可以分发和相互通信的独立程序,只要它们有彼此的地址。

So fundamentally, it is just about, in the same way that in Javafx I open a window, I would like to do the same with browser technology.所以从根本上说,就像我在 Javafx 中打开一个窗口一样,我想对浏览器技术做同样的事情。

Consequently, I would like to know, if it will be browser dependent or independent?因此,我想知道它是依赖于浏览器还是独立于浏览器? Will be done from Java or JavaScript ?将由 Java 或 JavaScript 完成?

You can use Desktop.getDesktop().browse(new URL("http://google.com").toURI());您可以使用Desktop.getDesktop().browse(new URL("http://google.com").toURI()); to open a new tab but you cannot open a new window.打开一个新标签,但您不能打开一个新窗口。 That will only happen if the user does not have a internet browser up.只有当用户没有启动互联网浏览器时才会发生这种情况。

https://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html#browse(java.net.URI) https://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html#browse(java.net.URI)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM