Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can jFrames be used inside of JavaFX?

I just saw a article on Swing being used in JavaFX. How can an application that uses a jFrame to display graphics be ported into JavaFX? Also, will the jButtons and jSliders work in the normal manner?

I know this is a generic question but I know little of JavaFX and am curious about porting some desktop applications to the web via the JavaFX package.

like image 306
WolfmanDragon Avatar asked Jan 12 '09 23:01

WolfmanDragon


People also ask

Can I use Swing components in JavaFX?

swing package. This class enables you to embed Swing content in a JavaFX application. To specify the content of the SwingNode object, call the setContent method, which accepts an instance of the javax.

Can you mix Swing and JavaFX?

JavaFX SDK provides the JFXPanel class, which is located in the javafx. embed. swing package and enables you to embed JavaFX content into Swing applications.

Why Swing is replaced by JavaFX?

JavaFX was intended to replace Swing as the standard GUI library for Java SE, but it has been dropped from new Standard Editions while Swing and AWT remain included, supposedly because JavaFX's marketshare has been "eroded by the rise of 'mobile first' and 'web first applications." With the release of JDK 11 in 2018, ...

Does JavaFX replace Swing?

In short, Swing and JavaFX are both GUI toolkits for Java programs. Swing is the old standard toolkit that features a bigger library of GUI elements and mature IDE support. JavaFX is the newer standard with a smaller library, more consistent updates, and consistent MVC support.


1 Answers

javafx file:

import javax.swing.JComponent;
import javafx.ext.swing.SwingComponent;

class NewFxComponent extends SwingComponent
{ 

    var comp: JComponent;

    public override function createJComponent():JComponent
    {
        return new OldJComponent();
    }

}
like image 93
l_39217_l Avatar answered Oct 08 '22 07:10

l_39217_l