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 8931287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:04:53+00:00 2026-06-15T09:04:53+00:00

I am working on a swing application using JavaFX controls. in this application i

  • 0

I am working on a swing application using JavaFX controls.
in this application i have three controls buttons WebView and JTable.
on clicking on button1 table should be added on the screen and web view should be removed while on clicking on other button
table should be removed and web view should be added.

I am using the following code.

  import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.web.*;
import javafx.stage.Stage;
import javafx.embed.swing.JFXPanel; 
import javafx.scene.Group;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
 public class webviewtestclass extends JFrame implements ActionListener {
 JFXPanel fxpanel,fxpanel1;
 static String filepath;
JTable table;
  public  webviewtestclass()
  {
    setLayout(null);
    JButton b1= new JButton("OK");
    JButton b2= new JButton("OKK");
    add(b1);
    add(b2);
    b1.setBounds(20,50,50,30);
    b2.setBounds(70,50,50,30);
   b1.addActionListener(this);
   b2.addActionListener(this);

   fxpanel= new JFXPanel();
   add(fxpanel);
   fxpanel.setBounds(10,50,1000,800);


   Object obj=new Object[50][20];
   String title[]={"head1","head2"};
    table=new JTable(title,obj);
   add(table);


 }

   public void actionPerformed(ActionEvent ae)
   {
   if(ae.getActionCommand().equals("OK"))
    {
     remove(fxpanel);
      add(table);   

     }
     if(ae.getActionCommand().equals("OKK"))
     {
      remove(table);
      add(fxpanel);   

    }
     Platform.runLater(new Runnable() {
     public void run()
      {
        initFx(fxpanel);
      }}
        );
     }



  private static void initFx(final JFXPanel fxpanel)
  {
    String htmlpath="d:/lcrux/html/";
    Group group= new Group();
    Scene scene= new Scene(group);
    fxpanel.setScene(scene);    
    WebView webview = new WebView ();
    group.getChildren().add(webview);
    webview.setMinSize(1200,800);
     webview.setMaxSize(1200,800);  

      webview.setVisible(true);
      final WebEngine eng = webview.getEngine();
      File htmlFile = new File(htmlpath+filepath);
        try
        {
        eng.load(htmlFile.toURI().toURL().toString());
        }
        catch(Exception ex)
        {
        }
    }
  public static void main(final String args[])
    {


         webviewtestclass frm=new webviewtestclass();
         frm.show();

    }


  }
  • 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-06-15T09:04:54+00:00Added an answer on June 15, 2026 at 9:04 am

    Put both components in a CardLayout to swap between them. Code using a CardLayout can be seen in this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a desktop (swing) application with Eclipse IDE. I have three comboboxes
I am working on a Java Swing Based application using Hibernate. And i have
I am working on a swing application with javafx control ( WebView ). In
I have a really strange issue. I am working on a Java SWING application
I have a calculator application in java swing, which is working properly with mouse
So I am working on a GUI application using the swing framework. In short,
I am working on the Java desktop application using Swing. As the application is
I am working on an application that uses Swing. I have a JTabbedPane, and
I am working on a swing application using JinternalFrames but when i open one
So I have a desktop application designed using the MVC pattern inspired by this

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.