How to use Swing Components in  JavaFX

Hi All,
I am new to JavaFx. I am trying to use java swing components in javafx.
I found a sample program in net and tried it. But it shows compile time error.
Code:
MySwingComponent .fx
import javafx.ext.swing.SwingComponent;
import javax.swing.JComponent;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
* @author nandha
class MySwingComponent extends SwingComponent{
var button: JButton;
public var text: String on replace {
button.setText(text);
public var action: function();
override protected function createJComponent () : JComponent {
button = new JButton();
button.addActionListener(ActionListener {
public override function actionPerformed(e:ActionEvent){
action();
return button;
The above code shows no error.
Test SwingButton.fx
import javafx.stage.Stage;
import javafx.scene.Scene;
import swingcomponents.MySwingButton;
* @author nandha
Stage {
title: "Swing Button Example"
scene: Scene {
width: 250
height: 80
content: [
MySwingButton{  // error message: imcompatible type. found MySwingButton. Required javafx.scene.Node[]
text: "Click Me!"
action: function(){
println("Hello World!");
This code which used the MySwingButton shows error: imcompatible type. found MySwingButton. Required javafx.scene.Node[] - where i have added the MySwingButton.
Please help me to fix the error.
Thanks &Regards,
Nandha K

Hi Sasa,
First thanks for your reply.
I found the problem and have fixed.
Problem:
There is no class MySwingButton in the package swingcomponents. Its MySwingComponent that i should have used, which is a big mistake that i have done. To my surprise i don't know NetBeans didn't show any error message at that line.
Thanks & Regards,
Nandha K

Similar Messages

  • Embedding Swing Components within Javafx Scene (on a Mac)

    Currently I trying to embed swing components into javafx through steps located here: SwingNode The Myth not the reality | In-SideFX
    Was able to get it working on a PC, however when the packaged jar is run on a mac, I end up with the "Headless exception"
    "Process manager already initialized: can't fully enable headless mode." (error attached below)
    Currently using java 7 update 51, using java 8 is not an option unfortunately.
    Does anyone know of a work around to get this working in mac or possibly point me in the right direction?
    Please let me know if providing other things would help. Thank you in advanced!

    Currently I trying to embed swing components into javafx through steps located here: SwingNode The Myth not the reality | In-SideFX
    Was able to get it working on a PC, however when the packaged jar is run on a mac, I end up with the "Headless exception"
    "Process manager already initialized: can't fully enable headless mode." (error attached below)
    Currently using java 7 update 51, using java 8 is not an option unfortunately.
    Does anyone know of a work around to get this working in mac or possibly point me in the right direction?
    Please let me know if providing other things would help. Thank you in advanced!

  • I can't use swing components in my applets

    When I write an applet without any swing components, my browser never has any trouble finding the classes it needs, whether they're classes I've written or classes that came with Java. However, when I try to use swing components it cannot find them, because it is looking in the wrong place:
    On my computer I have a directory called C:\Java, into which I installed my Java Development Kit (so Sun's classes are stored in the default location within that directory, wherever that is), and I store my classes in C:\Java\Files\[path depends on package]. My browser gives an error message along the lines of "Cannot find class JFrame at C:\Java\Files\javax\swing\JFrame.class"; it shouldn't be looking for this non-existent directory, it should find the swing components where it finds, for example, the Applet class and the Graphics class.
    Is there any way I can set the classpath on my browser? Are the swing components stored separately from other classes (I'm using the J2SE v1.3)?
    Thanks in advance.

    Without having complete information, it appears that you are running your applets using the browser's VM. Further, I assume you are using either IE or Netscape Navigator pre-v6. In that case, your browser only supports Java 1.1, and Swing was implemented in Java 1.2. You need to use the Java plug-in in order to use the Swing classes (see the Plug-in forum for more information), or else download the Swing classes from Sun and include them in your CLASSPATH.
    HTH,
    Carl Rapson

  • How to implement hyperlink in java using swing components

    hi.....
    pls help me to find out solution
    how to implement hyperlink in java using swing components

    I've got the same problem here.
    I want to implement a HyperlinkListener to a JLabel. (Unlike suggested above, it is only supported by JEditorPane and not JLabel)
    The goal is, that if a user clicks on a Link in a JLabel, the standard browser opens and displays that page.
    Can somebody please help?
    My ultimate goal would be to also be able to add clickable HyperLinks in ToolTip texts, but i guess that'd be even more complicated.

  • How to embed swing component into javaFX ?

    Maybe I missed sth, but can someone explain us how can we embed swing component into javaFX 2.0 ?
    This was previously handled with javaFX "srcipt", why can't we do it anymore ?
    As far as the work to migrate from 1.3 to 2.0 is hard and huge, why do fx2.0 do not offer such feature anymore ? :(
    I know that ThingFx project try to cope with, but the current code doesn't match with my needs.
    Thanks for help,
    Edited by: tibO on 23 nov. 2011 14:35

    I know this post is old and the original authors might not even ben active; but it essentiall gets to the heart of what I'm trying to.
    I have a JDialogBox. In it I have a panel (which I have to change to a JScrollPane). Inside the JPanel I have a JLabel and a JTextArea.
    I was told to; make it scrollable in the event that there is too much info for the JDialogBox and to add HTML formatting (simple stuff like bold and colors.
    1) The JScrollBar doesn't seem to produce the scroll side bars.
    2) I must not be implementing the JEditorPane correctly. I just substituted JEditorPane for JTextArea in my code and it returned a type converstion error. Is JEditorPane even the correct object to use? Should I be using JTextPane?
    The reason I can't do this on a JLabel by JLabel basis is because I don't know how many labels I will need at each runtime. And I also have to have a swingtimer on it. I could create an array and loop around it to create the JLabels. But it seems a waste of commuting cycles. This is no good?

  • Using Swing Components in JSP

    Hi,
    I regret that I do not have a very specific problem here. However, I am wondering if there is a way to display Swing components, such as a panel, on a web page using JSP. If so, are there any tutorials on such a practice? Or would something like this be included in a general tutorial?
    Thanks,
    Dan

    You'll have to use a JApplet.

  • How to add swing components in an applet

    hello friends;
    I encounterd one problem that is I created one applet which I derived from JApplet and now I want to add some swing components to that applet. I added them properly and when I am testing my applet in Appletviewer it is working fine but when I tested it in internet explorer it is not working. Please help me overcome this problem
    Thanks in advance.
    Amit

    IE does not support swing if you do not have the java-plugin installed. Either install that, then IE can display Swing components - or use AWT which can be displayed by IE.
    cheers,
    kelysar

  • How to use Swing in a web Application

    Can you suggest me some good PDF/tutorial or some good site for reading about using SWING in a Web Application.
    In our web application we plan to use JSP/Struts for the presentation layer. However there are a few screens that require some advanced UI like color coded assets and a graphical version of Outstanding Vs Available limit. We are wondering whether we should use SWING for these screens. Do you think this is a good idea or is there a better apprach to deal with this
    What are the disadvantages of using SWING VS JSP/Servlet in a Web environment. Is there a site or pdf where i can get information about this.

    I'd say the biggest disadvantage is that your client machines have to download and install the bloody java plug in.
    What you write about your UI ain't half vague. What the deuce is a "color coded asset"? Is it
    interactive? If not, could it be represented by an image? If so, even if it is a non-static image, it is a simple
    matter for your webapp to generate the image on the fly. Many web app tutorials demonstrate that.

  • How to use Swing in a Web applicatrion

    Can you suggest me some good PDF or some good site for reading about using SWING in a Web Application.
    In our web application we plan to use JSP/Struts for the presentation layer. However there are a few screens that require some advanced UI like color coded assets and a graphical version of Outstanding Vs Available limit. We are wondering whether we should use SWING for these screens. Do you think this is a good idea or is there a better apprach to deal with this
    What are the disadvantages of using SWING VS JSP/Servlet in a Web environment. Is there a site or pdf where i can get information about this.

    Applet/HTML page combinations are used often when a portion of a page requires Swing/AWT capabilities, e.g. administration consoles for Weblogic and JBoss are designed this way. The page is typically divided with frames that contain either applet or HTML code.
    A

  • Can I Use Swing Components in a JSP Page

    Hi,
    Can I use Swing Componnents in a JSP Page.If so,Can anybody provide with a sample code.
    Thanks.

    hi,
    I wanted to use the JTabbedPane for tab buttons in my
    Jsp Page.Is that possible?I am afraid that you can't.
    As for GUI (graphics) in the HTML page you can use only the html form elements (but you should simulate other behaviours by dynamically reloading the page).-
    Ionel.

  • How to use Flex Components with Flash?

    Hi!!
    I found a lot of very useful components in the web, but they are all for  Flex, is it possible to use Flex Components with Flash IDE?
    Thanks !!!
    jenry
    PS: this is one of the components I need to use (a tree with checkbox  nodes)
    http://www.sephiroth.it/file_detail.php?pageNum_comments=30&id=151
    another one:
    http://www.darronschall.com/weblog/2006/09/a-flex-2-checked-tree-control-component.cfm

    Flex components are delivered as SWCs just like Flash components, but the
    SWC format is incompatible with the Flash IDE.
    Also, the default fl.. components in the Flash IDE are incompatible with
    Flex components.
    You should be able to load a Flex SWF into a Flash SWF as long as you aren't
    using fl.. components in the Flash SWF.  If the Flex SWF overlays things
    in your Flash SWF then it might block interaction, but otherwise it
    shouldn't.  I don't think the statement you quoted is true for all
    configurations.
    But loading a Flex SWF into a Flash SWF isn't going to help you use those
    Flex components from your Flash IDE.  Try Flash Builder 4 to build out the
    Flex portion of your application.  I haven't tried it myself, but it I think
    it is supposed to have better integration with Flash.

  • How to use Swing in Web Applications

    Can you suggest me some good PDF or some good site for reading about using SWING in a Web Application.
    In our web application we plan to use JSP/Struts for the presentation layer. However there are a few screens that require some advanced UI like color coded assets and a graphical version of Outstanding Vs Available limit. We are wondering whether we should use SWING for these screens. Do you think this is a good idea or is there a better apprach to deal with this
    What are the disadvantages of using SWING VS JSP/Servlet in a Web environment. Is there a site or pdf where i can get information about this.

    As mentioned above, you could simply use an Applet, but I would discourage that approach.
    Although it's harder to have a good UI on the web, it's definitely possible (witness Gmail). You can do all sorts of clever things like building collapsible/expandable tree structures on the web with a little Javascript/CSS.
    Swing is much, much slower than regular HTML elements and the API for some Swing things is needlessly complicated (i.e. JTree).
    Could you be a bit more specific about the UI elements that you need? If you wanted to do something like Photoshop, well, it would be almost impossible on the web (to do it well at least), but many other applications are very do-able.

  • How to use swing 3d to do a menu list ?

    Is anyone know any good webpage to show some simples about swing 3d ? I want to do a menu which is using swing 3d . Thank you .
    regards
    jojo

    I've never mixed swing and Java3D but I've got the following URL in my bookmarks. Maybe it will help you.
    http://www.jroller.com/page/gfx/?anchor=a_swing_button_with_3d
    Bye!

  • How to use Swing html to parse a html file..

    I am currently working on a project in java.i need to read a Html file, extract the table tag along with its contents if it has a button embedded in it and replace it with another code..
    i tried it with Reg Ex in java but in vain.. Any help is great... I need an idea of how to use Html parser for this prob.. any examples will be fine..

    Run the program from command line, this way you will see the errors, if any.
    example.: java -jar theJarfile.jar
    I was successful in creating a comm application. I placed the win32com.dll in the same directory of my application jar file and all worked.
    I also extracted the comm.jar , and jar'd my app with the extracted comm files to make one jar.
    I also had a fileWriter() to get the clients jre path and my app would write the javax.properties file to the correct place.
    It took me severel weeks and late nights to accomplish this, but it was all necessary to be able to install only my app, and not a bunch of api's that were needed.

  • How to Use Swing-ADF in a Three-Tier-Archiitecture

    I am currently avaluating Swing-ADF (11g) and I wonder how I can leverage it in a three-tier, rich-thin-client-environment. When I bind a control, normally I would do it directly to the database. As I want to have my business logic and database access on the middle-tier, how do I bind my controls to the middle-tier which in turn accesses the database. Does ADF support a mechanism to bind the Swing-Client to the middle-tier-data? Is the recommended way to go for webservices? Can Webservices easily bound to the ADF-controls? Is it the only way?
    best regards
    Stefan

    Stefan,
    It is a built-in feature of ADF Business Components to expose an application module as a stateful EJB session bean to support three-tier Swing-client access. It requires absolutely no effort from the developer, who can even easily switch between running/testing in 2-tier or 3-tier modes. Shay's answer is valid for the general case, but in the specific case of what the ADF tech stack can bring to bear to solve your problem, it can be completely simple to achieve (even requiring zero code, if you choose to leverage that feature of ADFBC).

Maybe you are looking for

  • SDK 1.4 compilation problems

    I get the following error when I try to compile a java program in the 1.4 envt. There are no errors in 1.3 envt. home/skreddy/jsdk14/jre/lib/sparc/client/libjvm.so, because ld.so.1: xjavac: fatal: relocation error: file /home/skreddy/jsdk14/jre/lib/s

  • BUG ? : No more data to read from socket

    I have a problem while using the CURSOR function in a xsql:query with a where clause and an order by : Example : My xsql file : <xsql:query connection="demo" xmlns:xsql="urn:oracle-xsql"> select d.deptno as deptno, d.dname, CURSOR( select empno,ename

  • Oracle Performance tunning genral question

    Hi, Below is the list of Areas of Oracle db for which tunning activities are done. You are invited to comment to it weather this is complete list or need some addition or deletion. As I'm learning PT for Oracle now a days, therefore I want to expand

  • ABAP interfaces build using BDC and BAPIs can be used/replaced with the XI?

    Hi,   We have develeloped our interfases using BDC and BAPIs. Now our client has decited to implement XI. Now could you please help in finding whether these interfaces can be used/replaced with the XI.       If yes, please let us know how? Thanks and

  • Calling Function Modules Dynamically

    Hi All,        Is it possible to call a function module dynamically i.e. to pass the module name and the import and export parameters dynamically at runtime. Please provide a way of achieving this. Regards,              Milan Thaker