Using JavaFX to rewrite GUI layer for Java Desktop Swing application

From the faq's on javafx.com I read the following:
I currently build applications in Java. Can I reuse my Java libraries in JavaFX Script?
Yes. You can leverage the power of Java by using any Java library within a JavaFX application.
This way you can preserve your investment in Java and use JavaFX to build engaging visual experiences.
Can I use JavaFX to develop a user interface for my Java program?
While it's easy to write your application in JavaFX and call into Java where necessary,
the inverse - writing a Java application that calls into JavaFX for the user interface - is not yet true.
We expect this to be addressed in the near future.
* Perhaps I'm missing something, but I do not see the difference between the two questions, but they give completely different answers?
* We have a swing application that we might want to use JavaFX to replace the current Swing user interface, however, we also have alot of business logic / communications code written in
* Java that we aren't going to rewrite.
Could someone tell me why the two questions have different answers?
Thanks. Cheers.

Hi Josh,
I'm facing serious issue trying to invoke a javafx class from my java code. Could you please suggest a way to do it. Even hacks would be ood enough for now.
I have created file Clock.fx. When run individually from my IDE (i'm using NetBeans) it works fine. But when i try to invoke it from a java class in project in throws exception.
public static void main(String[] args) {
ScriptEngineManager manager = new ScriptEngineManager();
JavaFXScriptEngine fxEngine = (JavaFXScriptEngine) manager.getEngineByName("javafx");
System.out.print("created fxEngine");
try {
Object o = fxEngine.eval ("Clock { property: \"Clock\" }");
fxEngine.invokeMethod (o, "create");
} catch (Exception ex) {
ex.printStackTrace();
I get following exception
Exception thrown in JavaFX pretty printing: java.io.FileNotFoundException: \tmp\___FX_SCRIPT___.fxdump from StringInputBuffer (The system cannot find the path specified)
Exception thrown in JavaFX pretty printing: java.io.FileNotFoundException: \tmp\___FX_SCRIPT___.fxdump from StringInputBuffer (The system cannot find the path specified)
javax.script.ScriptException: compilation failed
at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.parse(JavaFXScriptEngineImpl.java:255)
at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.eval(JavaFXScriptEngineImpl.java:145)
at com.sun.tools.javafx.script.JavaFXScriptEngineImpl.eval(JavaFXScriptEngineImpl.java:136)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
at newpackage.Main.main(Main.java:29)
Could you please give a solution to it. I would be obliged.

Similar Messages

  • Any gui interface for java db (derby ) such as oracle give sqldeveloper

    hi master
    sir any gui interface for java db (derby ) such as oracle give sqldeveloper that create table and view only mouse clicking
    how i get derby gui interface
    thank'
    aamir

    try db visualizer
    http://www.minq.se/products/dbvis/

  • GUI toolkit for Java ME/ CDC devices

    I have written in my blog about:
    GUI toolkit for Java ME/ CDC devices: http://ovenordstrom.blogspot.com/2006/08/gui-toolkit-for-java-me-cdc-devices.html
    and
    ERCP - Embedded Rich Client Platform, soon with the first release of eRCP:
    http://ovenordstrom.blogspot.com/2006/08/ercp-embedded-rich-client-platform.html
    That perhaps is interesting for Java ME/PP developers
    Regards,
    Ove

    Hi there!
    I guess you should take a look at GTK+/Gnome development today.
    Cheers,
    Inge-Lars

  • Deployment issues-java desktop database application

    hello,
    i'm vasant...recently visited an online tutorial for creating java desktop database application
    here is the URL [http://www.netbeans.org/kb/docs/java/gui-db.html#running-outside-IDE] ...
    everything works fine...when building and executing the application from within the NetBeans IDE..6.7
    but as instructed in that tutorial...when I tried to run the .jar file after exiting the netbeans IDE, it didnt run...
    infact direction has been given in that tutorial for this in the last section....which says that i've to start Java DB from outside the Netbeans IDE...that's where difficulty arises....
    i've no idea how to start Java DB manually...
    i'd really appreciate if nybody der could...help me out plz
    thanx

    spring_patel wrote:
    i really appreciate you trying to solve my problem..
    but i think...my estion is fairly simple and straight forward...and i've provided every detail of my problem(if uv'e read my opening post of this thread)....
    and as far as that link goes...i've already checked it b4 u guys mentioned it... as it is provided right there in the tutorial i've provided link of...
    and i've tried my options b4 making use of this forum...and i didnt find a solution that's why i'm taking ur help..
    nevertheless...i repeat my question...
    there's a tutorial at this link...[http://www.netbeans.org/kb/docs/java/gui-db.html]...in it is described how to create a java desktop database applicaiton...
    at the end of the tuorial there is a section called: "Building and Deploying the Application"
    in that section they have instructed to exit netbeans IDE and try and run the application outside it...which is not happening
    the reason they say is that i've to start Java DB from outside of the IDE...that is wat my problem is ..
    i dont know how to start Java DB from outside the Netbeans ide...You are not telling us anything.
    If I tell you "my automobile doesn't work" how do you know what is wrong. Instead I need to tell you one of the following.
    1. The engine didn't start.
    2. The wheel fell off.
    3. The engine caught fire.
    4. When I went to the driveway the car wasn't even there.
    When you "run" something then something happens. When I run notepad from a console window if notepad is not in the path then I will get an error about command not found. if it is in the path then the command executes and notepad pops up. Even if I don't see notepad pop up I know that the command seemed to execute from the command window.
    The above are examples of describing what you did and what did happen. In detail.
    "It doesn't work" provides neither detail about how you ran it nor what did happen when you did attempt to run it.

  • Set a default Font for a whole Swing application?

    Hi,
    Is it possible to set "Courier" as the default font for a whole swing application?
    I seem to have gotten lost here, could someone give me some pointers please?
    Thank You,
    -Uday

    So it needs to be done right at the beginningYes.
    Is there a code sample i can look at for reference and a standard way of doing this.I've seen examples posted in the forum the use the UIManager.getDefaults() method and then iterate through the defaults looking for all properties that end with ".font" and then replace the font as required.

  • How do I rewrite current code for java 1.3

    I'm using the code below that is written for java 1.4. I have been told that the company can not push JRE 1.4 to the company, and that I need to write my code for java 1.3. I'm using org.w3c.dom for my create xml, etc.
    Is there a java 1.3 option to the 1.4? Any help would be very appreciated.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.List;
    import java.io.*;
    import java.util.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    import org.w3c.dom.*;
    public class Sametime extends JFrame implements ActionListener {
        private int indentation = -1;
        JPanel panel = new JPanel();
        JTextArea jta = new JTextArea(
        //Instructions for user
        "For a successful buddy list migration do the following:\n"
        + "1. Save your current Sametime Buddy List to your PC.\n   "
        + "The default location should be: C:/Program Files/Lotus/Sametime Client.\n"
        + "  A. Open the Sametime Client.\n"
        + "  B. Click on People\n"
        + "  C. Click on Save List.\n"
        + "  D. Save as your first.last.dat\n"
        + "     Ex. john.doe.dat\n"
        + "NOTE: If you have AOL contacts in your Sametime buddy list they will not be migrated.\n");
        JButton browse = new JButton("Continue");
        JButton exit = new JButton("Exit");
        public Sametime() {
            super("Sametime Buddy List Migration");
            setSize(610, 245);
            Container c = this.getContentPane();
            c.add(panel);
            browse.addActionListener(this);
            exit.addActionListener(this);
            panel.add(jta);
            panel.add(browse);
            panel.add(exit);
            jta.setEditable(false);
            setLookAndFeel();
            setVisible(true);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        } //end Sametime
        public class DATFilter extends javax.swing.filechooser.FileFilter {
            public boolean accept(File f) {
                //if it is a directory -- we want to show it so return true.
                if (f.isDirectory())
                    return true;
                String extension = getExtension(f);//get the extension of the file
                //check to see if the extension is equal to "dat"
                if ((extension.equals("dat")))
                    return true;
                //default -- fall through. False is return on all
                //occasions except:
                //a) the file is a directory
                //b) the file's extension is what we are looking for.
                return false;
            }//end accept
            public String getDescription() {
                return "dat files";
            }//end getDescription
             * Method to get the extension of the file, in lowercase
            private String getExtension(File f) {
                String s = f.getName();
                int i = s.lastIndexOf('.');
                if (i > 0 &&  i < s.length() - 1)
                    return s.substring(i+1).toLowerCase();
                return "";
            }//end getExtension
        }//end class DATFilter
        public void actionPerformed(ActionEvent e) {
            //Default Location for JFileChooser search
            String error = "The file selected is not a .dat file!\n"
            + "Please select your recently saved .dat file and try again.";
            JFileChooser fc = new JFileChooser("/Program Files/Lotus/Sametime Client");
            fc.setFileFilter(new DATFilter());
            fc.setFileSelectionMode( JFileChooser.FILES_ONLY);
            String user = System.getProperty("user.name");// finds who the current user is
            if (e.getSource() == browse) {
                int returnVal = fc.showSaveDialog(Sametime.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    //if (fc.getSelectedFile().getName().equals(".dat")){
                    if (fc.getSelectedFile().getName().endsWith(".dat")){ // checks to see if selected file is .dat
                    }else{
                        JOptionPane.showMessageDialog(null, error, "Wrong File", JOptionPane.ERROR_MESSAGE);
                        return;
                    }//end else
                    try {
                        String[] contactArray = parseDatFile(fc.getSelectedFile());
                        Document document = createXMLDocument(contactArray);
                        saveToXMLFile(
                        document,
                        new File(
                        "C:/Documents and Settings/" + user +"/My Documents/OLCS/",// looks for directory for list
                        "contacts-list_migration.ctt"));
                    } catch (Exception exc) {
                        File f = new File("C:/Documents and Settings/" + user +"/My Documents/OLCS/");// setting directory for list if not there
                        boolean yes = true;
                        yes = f.mkdir();// creating directory
                        try {
                            String[] contactArray = parseDatFile(fc.getSelectedFile());
                            Document document = createXMLDocument(contactArray);
                            saveToXMLFile(
                            document,
                            new File(
                            "C:/Documents and Settings/" + user +"/My Documents/OLCS/",// used only if the directory didn't exist
                            "contacts-list_migration.ctt"));
                            //exc.printStackTrace();// not sure if this is needed?
                        } catch (Exception exc1) {
                            exc1.printStackTrace();
                        }//end inner catch
                    }// end catch
                }// end if
                if(returnVal==JFileChooser.CANCEL_OPTION){
                    String Warning = "You did not migrate your Sametime buddy list at this time.";
                    JOptionPane.showMessageDialog(null, Warning, "Migration Canceled", JOptionPane.WARNING_MESSAGE);
                    return;
                }else{
                    String thankyou = "Thank You for Migrating your Sametime buddy list to OLCS"
                    + "\nYour new OLCS buddy list has been saved to:"
                    + "\nC:/Documents and Settings/" + user +"/My Documents/OLCS"
                    + "\n as: Contact-List_migration.ctt"
                    + "\n\n To be able to use Contact-List_migration.ctt for Windows Messenger:"
                    + "\n1. Log into Windows Messenger."
                    + "\n2. Click on File"
                    + "\n3. Click on 'Import Contacts from a Saved File...'"
                    + "\n4. Open OLCS in My Documents"
                    + "\n5. Click on 'Contact-list_migration.ctt'"
                    + "\n6. Click Open to import the list."
                    + "\n   A window will pop up confirming that you want to add all of the contacts"
                    + "\n   Click 'yes'"
                    + "\n   Your buddy list is ready to be used.";
                    JOptionPane.showMessageDialog(null, thankyou, "Migration Completed", JOptionPane.INFORMATION_MESSAGE);//Change this when defualt directory is known.
                }//end if else statement
            } //end if
            System.exit( 0 );
            if (e.getSource() == exit) {
                System.exit( 0 );
            } //end if
        } //end actionPerformed
        String[] parseDatFile(File datFile)
        throws Exception    {
            List list = new ArrayList();
            BufferedReader br = new BufferedReader(new FileReader(datFile));
            String line;
            while ((line = br.readLine()) != null) {
                line = line.trim();
                if (line.indexOf("U") != 0)
                    continue;
                int p = line.indexOf("::");
                if (p == -1)
                    continue;
                line = line.substring(p + 2).trim();
                if (line.indexOf("AOL") == 0)
                    continue;
                p = line.indexOf(",");
                if (p != -1)
                    line = line.substring(0, p);
                line = line.trim() + "@mci.com";
                if (list.indexOf(line) == -1)
                    list.add(line);
            }//end while
            br.close();
            String[] contactArray = new String[list.size()];
            list.toArray(contactArray);
            return contactArray;
        }// end String
        // setting up the XML file
        Document createXMLDocument(String[] contactArray) throws Exception {
            DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = dBF.newDocumentBuilder();
            DOMImplementation domImpl = builder.getDOMImplementation();
            Document document = domImpl.createDocument(null, "messenger", null);
            Element root = document.getDocumentElement();
            Element svcElm = document.createElement("service");
            Element clElm = document.createElement("contactlist");
            svcElm.setAttribute("name", "Microsoft RTC Instant Messaging");
            svcElm.appendChild(clElm);
            root.appendChild(svcElm);
            for (int i = 0; i < contactArray.length; i++) {
                Element conElm = document.createElement("contact");
                Text conTxt = document.createTextNode(contactArray);
    conElm.appendChild(conTxt);
    clElm.appendChild(conElm);
    }//end for
    return document;
    }// end Document
    void saveToXMLFile(Document document, File xmlFile) throws Exception {
    OutputStream os =
    new BufferedOutputStream(new FileOutputStream(xmlFile));
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");//puts information on seperate lines
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");//gives the XML file indentation
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(os);
    transformer.transform(source, result);
    os.close();
    }//end saveToXMLFile
    public static void main(String[] args) {
    Sametime st = new Sametime();
    ImageIcon picIcon = new ImageIcon(st.getClass().getResource("/images/mci.gif"));//Change when default is known!
    st.setIconImage(picIcon.getImage());
    } //end main
    private void setLookAndFeel() {
    try {
    UIManager.setLookAndFeel(
    UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.updateComponentTreeUI(this);
    } catch (Exception e) {
    System.err.println("Could not use Look and Feel: " + e);
    } //end catch
    } //end void setLookAndFeel
    } //end public class Sametime

    Are there features of Java 1.4 that you specifically took advantage and are there any particular lines you are having problems with or did you just freak and post it here?
    Basically compile it under Java 1.3 and see what complains. I've done several projects that compile under 1.2, 1.3, and 1.4.

  • Webinar (Aug 11): How to create Cross-Platform Automated GUI Tests for Java Apps

    Join Squish expert, Amanda Burma, and learn how to create cross-platform automated GUI tests for your Java applications!
    Register here (multiple time slots)
    August 11th 2014
    Duration: 30 minutes plus Q & A
    This webinar will cover:
    General Squish for Java overview
    Automating BDD Scenarios
    Executing Cross-Platform Automated GUI Tests
    Interacting with Java application objects, properties & API
    See you there!
    Unable to attend? Register and we'll send links to future events and access to our webinar archive following the event.
    Webinar schedule
    Learn more about Squish
    Evaluate froglogic squish

    <property name="messaging.client.jar.path" value="Location in your local drive" />
    <property name="messaging.client.jar.name" value="nameOfYourFile.jar" />

  • Setting default volume level for Java Desktop

    Hello,
    I am running Sol 10 11/06 for sparc. How do I permanently set the default volume level for the Java desktop? If I change the volume manually and "save settings" on logoff, the saved setting is not saved after a reboot, after which I have to set it again.
    Thank you......

    Annoying, isn't it?
    Unfortunately the only thing you can do is lower your system volume before opening those pages. The volume could be controlled by the Web page author but most are clueless.

  • Product homepage for Java Desktop System?

    Where can I learn more about the product?

    The product home page is a good source of detail on the Java Desktop System: sun.com/javadesktopsystem.

  • How to open the link in new firefox window for web desktop based application? Or how to open the mail/website/rss link in new firefox window

    I am using the firefox 3.6. My problem is that I am using the web desktop and few web desktop based application directly opens link. If I click on rss link than it opens in same window, so no longer access to web desktop. I want to open any kind of link in new window instead of same window. I have tired to change the value of browser.link.open_newwindow, browser.link.open_newwindow.restriction but doesn't work. Also gone through the https://developer.mozilla.org/en/window.open but not sure where to do this in web desktop based application or firefox where we connect the web desktop?
    Is there any way to open the link every time in new firefox window?

    Hi Joseph,
    the HTMLB link object misses the support for onClientClick through the tag lib, see hbj:link without onClientClick ? and OnClientClick Event for Link HTMLB Component for similiar problems and workarounds.
    With this workaround, you can call for example an AbstractPortalComponent, implement doOnNodeReady (with an empty doContent method) and return the PDF, settings the content type on the http before etc.
    Hope it helps
    Detlev
    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • Tuning GC parameters for a large Swing application

    Our Swing application suffers from periodic out-of-memory errors. We have been trying to tune the application with limited sucess.
    The problem is full GC is called only when it is close to the maximum memory. As a result when it reaches the max-heap-size values, it takes a long time to complete GC and the application hangs.
    My current jnlp settings are as follows:
    <j2se version="1.5+" href="http://mydomain/myapp/jre" initial-heap-size="64M"
      max-heap-size="384M"
      java-vm-args="-verbose:gc -Dsun.java2d.noddraw=true -XX:NewSize=16m -XX:SurvivorRatio=8 -XX:YoungGenerationSizeIncrement=5 -XX:TenuredGenerationSizeIncrement=5 -XX:AdaptiveSizeDecrementScaleFactor=5" />I am looking at ways by which the tenured generation too gets garbage collected peiodically. Is there a way by which I can achieve this?

    for first one, try paintImmediately(rectangle) method. for second one, i guess Graphics g = panel.getGraphics();
    g.drawRect(....);

  • IMP:ClassCastException while using File upload UI in Webdynpro for java

    Hi All,
    I have used a FileUpload UI element in my screen , which is working fine for only the first time we upload a file. If we try to upload any file with out refreshing the application , a ClassCastException is being thrown. Please help me in resolving the issue.
    Thanks in advance.
    Srikanth

    Thank you!!
    1. But when i use the File Upload UI and try to use the 'data' property to retrieve the bytes i am getting a null pointer exception meaning the data is not being picked up by the UI even though browsed file has data.
    2. How I am I supposed to set the 'Resource' property while downloading a PDF which has UTF-16 text and picture??
    Note: I have done the same scenario using WD04 java without any trouble.
    reg
    vln

  • Using the Portal Single Sign-On for java applet clients

    Hi
    We have a task to build a java applet working within a portlet and comunicating to some session EJB(wrapped BC4J) running on the OC4J. The applet is presumably connecting to server via RMI. This connection should be restricted to some groups of portal users.
    When a user is entering the applet he is supposed to be already logged into the Portal.
    There is a lot of information on building custom secure portlets using only a pure HTML(same as JSP) client whith the help of the Portal Single Sign-On.
    But, is it possible to use the Single Sign-On for establishing a secure RMI connection from applet to OC4J without entering a password in the applet once more?
    Yuriy

    Perhaps you can write a small JSP page or PLSQL
    web procedure that will grab user name from
    the SSO Server (via SSOSDK/mod_osso)
    and invoke the applet with encrypted user name.
    The applet will receive the encrypted username
    and decrypt it to get the clear user name.
    This help to get Single Sign-On.
    To make sure that environment is secure, encrypted
    user name parameter should have random salt,
    user name, and time stamp to prevent replay attack.
    Applet must make sure that the encrypted users name
    time stamp set by the JSP/PLSQL page has value
    within a reasonable time limit like 5 minutes

  • Gui support for java

    hello friends,
    i am new to SUN fortran compiler. i have installed it. But what i have heard it has a gui interface to write fortran code and debug it. But i cant find it. is my installation incomplete or i am missing something? Command line compilation is working fine.

    There should be a sunstudio command. That will start the IDE (integrated development environment), which has an editor, debugger, and performance analysis tools.

  • How Get GUI Cycles for a Compute-Bound Application?

    Mine's not even quite compute-bound:
    o it sleeps for a millisecond in the loop
    o it does Thread.yield()
    ..but still the GUI never seems to get enf cycles for me to hit the stop btn.
    I didn't find anything in SwingUtilities.
    Thanks,
    -- M.

    You're almost certainly doing work on the event dispatch thread.
    http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
    Cheers,
    Laird

Maybe you are looking for