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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:47:51+00:00 2026-06-15T13:47:51+00:00

I want to hide and show FXPanel controls in javaFx application in swing I

  • 0

I want to hide and show FXPanel controls in javaFx application in swing

I want on clicking a button FXPanel control should be hidden and on clicking other the control should be again visible it is being hidden not being visible again.

using the following code.

public class abc extends JFrame
{
JFXPanel fxpanel;
Container cp;
public abc()
{
cp=this.getContentPane();
cp.setLayout(null);
JButton b1= new JButton("Ok");
JButton b2= new JButton("hide");
cp.add(b1);
cp.add(b2);
b1.setBounds(20,50,50,50);
b2.setBounds(70,50,50,50);
b1.addActionListener(this);
b2.addActionListener(this);
fxpanel= new JFXPanel();
cp.add(fxpanel);
fxpanel.setBounds(600,200,400,500);
}

public void actionPerformed(ActionEvent ae)
{ 
 if(ae.getActionCommand().equals("OK"))
 {
fxpanel.setVisible(true);
 }
   if(ae.getActionCommand().equals("hide"))
 {
 fxpanel.hide();
 }

 Platform.runLater(new Runnable())
{

 public void run()
 {
  init Fx(fxpanel);
  }}
 );
 }
 private static void initFX(final JFXPanel fxpanel) 
{
  Group group = ne Group();
  Scene scene= new Scene(group);
  fxpanel.setScene(scene);
  WebView webview= new WebView();
  group.getChildren().add(webview);
  webview.setMinSize(500,500);
  webview.setMaxSize(500,500);
  eng=webview.getEngine();
  File file= new File("d:/new folder/abc.html");
  try
 {
 eng.load(file.toURI().toURL().toString());
 }
catch(Exception ex)
{
}
}
public static void main(String args[])
{
 abc f1= new abc();
 f1.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-15T13:47:52+00:00Added an answer on June 15, 2026 at 1:47 pm

    Aside from a number of typos, there’s multiple issues with your code:

    1) If you are using ActionEvent#getActionCommand to determine which button was clicked, you have to set the action command property on the button first. The action command ist not the same as the button’s text.

    2) You are adding both buttons with the same coordinates, hence one will not show.

    3) Don’t use the deprecated hide()-Method to hide the JFXPanel, use setVisisble(false)

    Furthermore, a few general pointers:

    4) Don’t use null layout for a normal UI. Ever.

    5) Read up on the java naming convention. This is not just me being picky, it will help you better understand other people’s code and help other people maintain yours.

    6) Invoke the code that displays your swing components from the EDT via SwingUtilities#invokeLater, just as you used the Platform class. Invoking swing from the main thread like you did will work most of the times, but induce occasional errors that will be hard to track.

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

Sidebar

Related Questions

I want to dynamically hide/show controls in an activity based on a button touch
In my application I want to show/hide a button according to the users authorization
I want to hide/show items and show them again if requested. I am using
I want to hide and show a button on a particular condition in JavaScript.
I want to Show/Hide image by jQuery by clicking on same <div>. I can't
I want to show/hide jqgrid delete button on the basis of specific data in
I have a grid that has multiple rows. I want to hide/show one of
I want to achieve hide/show with div's in html but in this way. Here
all I want to show hide some ids using jQuery. My html code is
I have a program that I want to either hide or show certain UIbuttons

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.