|
|
|
mimoh_mi (m)
|
Let compare two code that uses Java Swing and JavaFx. I just want to show the ease of use. So, let's get codes that that display a button. Am using netbeans 5.5
Here is the swing code.
package javaswingapp; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*;
/** * * @author Musa */ public class Main extends JFrame{ JFrame frame; JButton btn; /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public void buildUi(){ frame = new JFrame(); btn = new JButton("Press Me"); frame.getContentPane().add(btn); // btn.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // btn.setText("Am Pressed"); // } // }); frame.setTitle("Swing Demo"); frame.setSize(400,500); frame.setVisible(true); } public static void main(String[] args) { // TODO code application logic here Main m = new Main(); m.buildUi(); } }
JavaFX Code
import javafx.ui.*;
Frame{ title: "Press Me" width: 200 content:Button { text:"Press me" } visible: true };
Notice how declarative it is. Under the hood, it is still a swing appearance
|
|
|
|
|
|
Seun (m)
|
The problem I have with JavaFX is the size of what people have to download before they can use your application. This is not an issue with software packaged on a CD or DVD or corporate software, but it's a problem for web-based software.
|
|
|
|
|
|
mimoh_mi (m)
|
@Seun
Hey, long time. Been out of the forum for a while now. Actually, most of the JavaFx example online uses the Java Network Launch Protocol. That means you have to run them with javaws tool available with the jdk. To run, just use javaws -offline <your-jnlp-file-name>. You can use just type the command without any option to display other available options. Also, you can click the java Web start icon in your control panel for the GUI version.
For deployment, you often deploy the application as a jar file. Well, I think, it JavaFx is going to be a thing for the future. Thanks
|
|
|
|
|
|