开发者

what is the difference between java desktop application and javafx?

What is the difference between a "normal" Java desktop application (with AWT or Swing), and a Java application built wit开发者_开发问答h JavaFX?

What are the advantages and disadvantages of each?


I think what you are asking is what are the pros and cons of building a JavaFX desktop application vs a Java Swing desktop application. After experimenting with both I can point out a few differences:

Java Swing

Pros:

  • Better visual designer and IDE support
  • More full featured set of controls
  • Good for building business applications such as user interfaces on top of a database where you don't need capabilities beyond the standard (and third party) controls.

Cons

  • Poor multimedia support
  • Building custom controls or custom skins is very difficult
  • No animation support
  • Java syntax can be awkward for building UIs. The IDE makes this less of an issue, but if you ever have to do anything manually it can get ugly.

JavaFX

Pros

  • Decent multimedia support
  • Easy to build custom controls, and all existing controls are skinnable using CSS (I haven't tried CSS yet though).
  • Animation support is good - not quite as good as flash but its good enough for basic animations.
  • The syntax seems better suited for building UIs, especially for hand coding them - which is good because you will need to hand code them.
  • Good for building multimedia applications or applications where you need a custom look.

Cons

  • The visual designer needs work, and personally I don't use it. This can be a big negative depending on your needs.
  • Still lacking in some controls, but this is getting better. The controls that do exist seem to work well.
  • Swing integration exists, but they are working on changing the engine so that it no longer relies on Swing. It is uncertain how well using Swing controls from JavaFX will work on the future. So I wouldn't avoid the use of Swing controls in JavaFX when possible.


JavaFX is improving faster and becoming better to use than Swing.

JavaFX is a framework for the GUI with several benefits, including animations and CSS integration. This can help in creating a lot of the 2D and near-3D stuff you can see in CSS3.

JavaFX is pure Java, so you need not learn another language other than the good old Java you know. JavaFX is my favorite GUI platform for desktop and enterprise, and I only use Swing when dealing with older application environments (i.e. integrating with hardware). The only disadvantage I know of is that the scene builder is not yet integrated, and using the controls and API requires some brain work, but this is minor.

For me there is no difference between Java desktop and JavaFX since JavaFX can be used to develop desktop apps, enterprise apps, and applets. You can look into the current JavaFX versions to check out its capabilities.


Its not a disadvantage/advantage situation as much as understanding what each can provide and the old saying "use the right tool for the job".

Answer from yahoo answers Source for this answer:

javaFX is actually a different language (similar, but different syntax), but it runs on a JVM and can use Java classes. Mainly developed for "RIA" (rich Internet applications), across a variety of devices. Quite a few built-in features for developing fancy & flashy user-interfaces, without all the typing one has to do in a more nuts-n-bolts (low-level) language like Java.

Really, it's kinda hard to "compare"; JavaFX leverages all the advantages of Java & builds a platform on it for developing RIA's.

  • JavaFX requires a JVM; but just having Java doesn't mean you have JavaFX.
  • thus, JavaFX is not inherently a part of Java.
  • any platform that doesn't support Java would therefore not support JavaFX (....i.e., iPhone, iPad) -- yet.
  • note that the iPhone & iPad also don't support Flash, a similar competitor in this space. (...Perhaps Flex or Silverlight are better examples of competing technologies....)

Source(s):
Javafx wikiepdia
javafx at a glance
javafx homepage similar stackoverflow question


The JTable class is another Swing component that has no equivalent in AWT. JTable provides a very flexible possibility to create and display tables. Lets build tables from arrays or vectors of objects or from objects that implement the TableModel interface.

The JTableModel interface defines methods for objects that specify the contents of a table. The class provides an implementation AbstractTableModel the JTableModel predetermined interface. This class is typically extended to provide a custom implementation of model table. The JTable class provides the ability to edit tables. the method setCellEditor () allows an object of the interface is TableCellEditor identified as the editor table cells.

import java.awt.*; 
import javax.swing.*; 
import javax.swing.table.*; 
public class JavaExampleTableInJApplet extends JApplet 
 { 
    Object[] Dt = new Object[5]; 
    DefaultTableModel DfltTblModl = new DefaultTableModel(); 
    JTable Tbl = new JTable(DfltTblModl); 
    public void init() 
     { 
        for(int clmn = 0; clmn < 5; clmn++) 
           { 
             DfltTblModl.addColumn("Column"+clmn); 
           } 
             for(int row = 0; row < 10; row++) 
             { 
                     for(int clmn = 0; clmn < 5; clmn++) 
                  { 
                          Dt[clmn] = "Cell " + row + "," + clmn; 
                      } 
                          DfltTblModl.addRow(Dt); 
                 } 
                    getContentPane().add(new JScrollPane(Tbl)); 
      } 
  } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜