在桌面应用程序中加载网页

时间:2022-12-20 20:00:50

As i am good in HTML and CSS, I want to make desktop application and mobile apps on one platform so that it will load an HTML page at runtime. My second purpose of doing that is, because if i update the webpage, the desktop application automatically gets updated.

由于我擅长HTML和CSS,我想在一个平台上制作桌面应用程序和移动应用程序,以便它在运行时加载HTML页面。我这样做的第二个目的是,因为如果我更新网页,桌面应用程序会自动更新。

I will prefer java because it can be used across multiple platform. I wants to render the page as Google Chrome renders it.

我更喜欢java,因为它可以在多个平台上使用。我希望在Google Chrome渲染时呈现该页面。

I want to make all types of application as a desktop application

我想将所有类型的应用程序作为桌面应用程序

  • Windows
  • Mac

I also wants to make all kinds of mobile application

我也想制作各种移动应用程序

  • Android
  • BlackBerry OS
  • iOS
  • Symbian OS
  • Java Mobile Application
  • Java移动应用程序

Any platform welcome.

任何平台欢迎。

Thanks in advance.

提前致谢。

3 个解决方案

#1


1  

Java has classes that can render basic html.

Java具有可以呈现基本html的类。

If you want something better you have to use a web browser. I would probably go with QtJambi and Webkit.

如果你想要更好的东西,你必须使用网络浏览器。我可能会选择QtJambi和Webkit。

#2


0  

I think you can use a JEditorPane to view a web page.

我认为您可以使用JEditorPane来查看网页。

try this:

import javax.swing.text.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;

public class OReillyHomePage {

  public static void main(String[] args) {

     JEditorPane jep = new JEditorPane();
     jep.setEditable(false);   

     try {
       jep.setPage("http://www.oreilly.com");
     }
     catch (IOException e) {
       jep.setContentType("text/html");
       jep.setText("<html>Could not load http://www.oreilly.com </html>");
     } 

     JScrollPane scrollPane = new JScrollPane(jep);     
     JFrame f = new JFrame("O'Reilly & Associates");
     // Next line requires Java 1.3
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     f.getContentPane().add(scrollPane);
     f.setSize(512, 342);
     f.show();

  }

}

reference: Using a JEdtiroPane to dispaly a web page

参考:使用JEdtiroPane显示网页

#3


0  

You didn't mention what ui toolkit you were going to use. The default would be to Swing and if you want to go that route then I would recommend DJ Native Swing. It gives you a true native browser that can be embedded into your application.

你没有提到你将要使用的ui工具包。默认是Swing,如果你想走那条路,我会推荐DJ Native Swing。它为您提供了一个真正的本机浏览器,可以嵌入到您的应用程序中。

Another choice is to use SWT which has a browser component build right into the toolkit. Take a look at the Javadoc or this simple tutorial.

另一种选择是使用SWT,它在浏览器组件中构建了工具包。看看Javadoc或这个简单的教程。

#1


1  

Java has classes that can render basic html.

Java具有可以呈现基本html的类。

If you want something better you have to use a web browser. I would probably go with QtJambi and Webkit.

如果你想要更好的东西,你必须使用网络浏览器。我可能会选择QtJambi和Webkit。

#2


0  

I think you can use a JEditorPane to view a web page.

我认为您可以使用JEditorPane来查看网页。

try this:

import javax.swing.text.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;

public class OReillyHomePage {

  public static void main(String[] args) {

     JEditorPane jep = new JEditorPane();
     jep.setEditable(false);   

     try {
       jep.setPage("http://www.oreilly.com");
     }
     catch (IOException e) {
       jep.setContentType("text/html");
       jep.setText("<html>Could not load http://www.oreilly.com </html>");
     } 

     JScrollPane scrollPane = new JScrollPane(jep);     
     JFrame f = new JFrame("O'Reilly & Associates");
     // Next line requires Java 1.3
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     f.getContentPane().add(scrollPane);
     f.setSize(512, 342);
     f.show();

  }

}

reference: Using a JEdtiroPane to dispaly a web page

参考:使用JEdtiroPane显示网页

#3


0  

You didn't mention what ui toolkit you were going to use. The default would be to Swing and if you want to go that route then I would recommend DJ Native Swing. It gives you a true native browser that can be embedded into your application.

你没有提到你将要使用的ui工具包。默认是Swing,如果你想走那条路,我会推荐DJ Native Swing。它为您提供了一个真正的本机浏览器,可以嵌入到您的应用程序中。

Another choice is to use SWT which has a browser component build right into the toolkit. Take a look at the Javadoc or this simple tutorial.

另一种选择是使用SWT,它在浏览器组件中构建了工具包。看看Javadoc或这个简单的教程。