Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between Swing, SWT and Jfaces?

 
yamini nadella
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are these SWT and JFaces. are they enhancements of Swing. according to my knowledge Swing is enhancement of AWT.
 
Scott Delap
author
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AWT was the original UI toolkit included in Java. It makes use of native peers for UI components. Swing takes a different approach by implementing all of its components with pure Java code. Swing uses a few portions of AWT such as the top level window containers and the AWT mechanisms for collecting input events such as mouse and keyboard clicks. However, it does not make use of the AWT components themselves.

http://www.javaworld.com/javaworld/jw-01-1998/jw-01-jfc.html

SWT uses a native peer approach similar to AWT. There is a JNI accessed layer that is different for each OS supported by SWT that contains peers for native components. So the SWT Table class ultimately delegates the majority of its functionality to the native Windows table component for instance. JFace is a layer built on top of SWT that simplifies common UI programming tasks and promotes a model based structure for using SWT components.

http://www.javaworld.com/javaworld/jw-04-2004/jw-0426-swtjface.html

http://www.martinfowler.com/eaaCatalog/modelViewController.html

Scott Delap
ClientJava.com
Desktop Java Live
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I havent been able to figure out what makes JFACE any easier to implement than SWT. It seems like it only saves you a few lines of code here and there. For example, JFace claims to streamline event handling by implementing the Action Class. But how is adding an "action class" any less tedious than adding an "action listener" ?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by JAY asasd:
I havent been able to figure out what makes JFACE any easier to implement than SWT. It seems like it only saves you a few lines of code here and there. For example, JFace claims to streamline event handling by implementing the Action Class. But how is adding an "action class" any less tedious than adding an "action listener" ?


For 1, and this applies to Swing also, Action classes are reuasable. Instead of writing the actionPerformed (Swing) method for every button give the button an instance of your action class.

The other thing JFace does is it takes care of all the garbage collection for you that you have to do manually in SWT. Remember that in SWT you have to manually dispose of certain components because they are drawn by the OS and the VM's GC has no control over them.

There is a bit of window creation code that is taken care of for you. Complex components like Tables and their models are better in JFace. Just things like that are what I think make JFace easier to use. Although remember also that JFace couldn't exist without SWT. If you look at the JFace classes, they are all SWT internally. So they saved you from having to implement all those JFace classes manually.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic