Skip to main content

Java from JavaFX

Posted by malenkov on March 31, 2009 at 8:00 AM PDT

The most powerful advantage of JavaFX is an easy use of Java classes. However, you can encounter an issue when calling some methods, for example, those that have the insert and delete names. The File class contains the delete method. How would you delete a file from JavaFX?

The issue here is that the insert and delete names are JavaFX keywords used for sequences. If you try to compile a code that uses the delete method, you will get the following error message.

Sorry, I was trying to understand an expression
but I got confused when I saw 'delete' which is a keyword.
new java.io.File("temp").delete();
                         ^

To solve this issue, use double angle brackets.

new java.io.File("temp").<<delete>>();

But that's the half of the story so far! This syntax allows any text line to be used as an identifier.

def <<english
      variable>> = "any symbols can be used as identifier";
def <<русская переменная>> = <<english
      variable>>;
println(<<русская переменная>>);

Note that CR/LF is a part of the identifier above. You can use a funny mug as a name for a debugging function:

function << o.O >> (error) {
  println("ERROR: {error}")
}
<< o.O >> ("WTF!");

The code above prints ERROR: WTF!

Related Topics >>

Comments

I never tryed to access any databases. You can start from here: http://blogs.sun.com/kenji/entry/how_to_connect_data_base Seems it should work.

Hi Sergey, thanks for all the interesting topics you have discussed. I had a question "kinda" related to 'Java from JavaFX'. I am trying to connect a desktop JavaFX application to an Access database. I know that you can use Java to connect, however all the samples I have seen are for the preview SKD and do not work for the current release. Do you have any samples or insight regarding the best way to do this? Thanks!