Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6907215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:24:27+00:00 2026-05-27T08:24:27+00:00

I was looking for a way to integrate a Web-Browser-Component in an existing Swing-Application

  • 0

I was looking for a way to integrate a Web-Browser-Component in an existing Swing-Application and found WebView for Java FX 2.0. Furthermore I found a blog post on java.net showing how to integrate a Java FX component into a Swing Application . So I guess it might be doable, but I haven’t tried yet.

I’m curious, do you think this is a good approach? Are there any better solutions? Is it even doable? Is maybe something prebundled out there?

The motivation is: I want to integrate some WebBrowser-whatever into an existing Swing-Application, the long-term goal being to get rid of the whole Java Desktop Application at all, replacing it with a web-based solution (the plan is to slowly convert existing aspects into webpages which are then displayed in the WebBrowser-Component until nothing is left of the swing application except for the browser-skeleton). The backend of course remains Java 🙂

I haven’t tried yet since I simply lack the time to integrate JavaFX with my project (its a job, we’re just exploring alternatives fpr the long run), so I better ask before I get burned.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:24:27+00:00Added an answer on May 27, 2026 at 8:24 am

    It is very well possible!

    One has to install JavaFX 2.0, and somehow manage to have jfxrt.jar in the Classpath.

    The following code renders a JFXPanel inside a JFrame. The JFXPanel contains a WebView which loads google.com.

    However, at least on my machine, the WebView feels rather sloppy. I’m working on Mac OS X 10.6; JavaFX 2.0 is still in beta for OS X.

    Alternatives I found include MozSwing, which looked very promising and feels quite fast actually. Sadly the project is not being developed any further since 2008 and the bundled XUL runner is rather old (no new fancy html 5).

    Both approaches are a nightmare to include via maven, you better setup your own local repository.

    import java.awt.Dimension;
    import java.awt.Point;
    
    import javafx.application.Platform;
    import javafx.embed.swing.JFXPanel;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.web.WebEngine;
    import javafx.scene.web.WebView;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    
    public class JavaFX {
    
        /* Create a JFrame with a JButton and a JFXPanel containing the WebView. */
        private static void initAndShowGUI() {
            // This method is invoked on Swing thread
            JFrame frame = new JFrame("FX");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            frame.getContentPane().setLayout(null); // do the layout manually
    
            final JButton jButton = new JButton("Button");
            final JFXPanel fxPanel = new JFXPanel();
    
            frame.add(jButton);
            frame.add(fxPanel);
            frame.setVisible(true);
    
            jButton.setSize(new Dimension(200, 27));
            fxPanel.setSize(new Dimension(300, 300));
            fxPanel.setLocation(new Point(0, 27));
    
            frame.getContentPane().setPreferredSize(new Dimension(300, 327));
            frame.pack();
            frame.setResizable(false);
    
            Platform.runLater(new Runnable() { // this will run initFX as JavaFX-Thread
                @Override
                public void run() {
                    initFX(fxPanel);
                }
            });
        }
    
        /* Creates a WebView and fires up google.com */
        private static void initFX(final JFXPanel fxPanel) {
            Group group = new Group();
            Scene scene = new Scene(group);
            fxPanel.setScene(scene);
    
            WebView webView = new WebView();
    
            group.getChildren().add(webView);
            webView.setMinSize(300, 300);
            webView.setMaxSize(300, 300);
    
                // Obtain the webEngine to navigate
            WebEngine webEngine = webView.getEngine();
            webEngine.load("http://www.google.com/");
        }
    
        /* Start application */
        public static void main(final String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    initAndShowGUI();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently looking for a possible way to integrate my C++/C# application with
I am looking for the best way to integrate Git with Ant. Is there
I'm looking a way to enable IP logging with log4net in ASP.NET. I found
I'm looking a way to build conditional assignments in bash: In Java it looks
I'm going to need to integrate a Java application that I wrote with a
Being compelled by the advantages I'm looking for a way to integrate generic programming
We're looking for the best way to integrate dynamic content into emails sent by
I'm looking for the best/easiest way to add extensions to an existing protocol (can't
I'm looking for a way to integrate Eclipse/Mylyn with github's project- issues . I'm
I am looking to write an extension that will integrate with the Web of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.