Content deleted Content added
Tags: Reverted section blanking |
Reverted 2 edits by 112.134.21.133 (talk): Section blanking |
||
Line 12:
In December 2008, [[Sun Microsystems]] (Oracle's predecessor) released the [[Cascading Style Sheets|CSS]] / [[FXML]] based framework that it intended to be the successor to Swing, called [[JavaFX]].<ref>{{Cite web|url=https://opensourceforu.com/2017/07/developing-basic-gui-application-using-javafx-eclipse/|title=Developing a basic GUI application using JavaFX in Eclipse}}</ref>
==History==
<!-- ''For the origin of the name ''Swing'', see [[List of computer term etymologies#S|List of computer term etymologies]].''
^^^^^ this should be moved in here -->
The [[Internet Foundation Classes]] (IFC) were a [[graphics library]] for Java originally developed by [[Netscape Communications Corporation]] and first released on December 16, 1996. On April 2, 1997, [[Sun Microsystems]] and [[Netscape Communications Corporation]] announced their intention to incorporate IFC with other technologies to form the [[Java Foundation Classes]].<ref>{{cite web
|url = http://www2.prnewswire.com/cgi-bin/stories.pl?ACCT=104&STORY=/www/story/84048&EDATE=
|title = Sun and Netscape to jointly develop Java Foundation Classes
|publisher = [[Netscape Communications Corporation]]
|date = 1997-04-02
|access-date = 2011-08-08
|url-status = dead
|archive-url = https://web.archive.org/web/20120509230952/http://www2.prnewswire.com/cgi-bin/stories.pl?ACCT=104&STORY=%2Fwww%2Fstory%2F84048&EDATE=
|archive-date = 2012-05-09
}}</ref> The "Java Foundation Classes" were later renamed "Swing."
Swing introduced a mechanism that allowed the [[look and feel]] of every component in an application to be altered without making substantial changes to the application code. The introduction of support for a [[pluggable look and feel]] allows Swing components to emulate the appearance of native components while still retaining the benefits of platform independence.
Originally distributed as a separately downloadable library, Swing has been included as part of the [[Java Platform, Standard Edition|Java Standard Edition]] since release 1.2.<ref>{{cite web|url=http://www.sun.com/smi/Press/sunflash/1998-12/sunflash.981208.9.xml |title=SUN DELIVERS NEXT VERSION OF THE JAVA PLATFORM |date=August 2007 |publisher=[[Sun Microsystems]] |quote=''The Java Foundation Classes are now core to the Java 2 platform and includes:The Project Swing set of GUI components, Drag & Drop, Java 2D API which provides new 2D and AWT graphics capabilities as well as printing support, The Java look and feel interface, A new Accessibility API '' |access-date=2012-01-08 |url-status=unfit |archive-url=https://web.archive.org/web/20070816170028/http://www.sun.com/smi/Press/sunflash/1998-12/sunflash.981208.9.xml |archive-date=August 16, 2007 }}</ref> The Swing classes and components are contained in the {{Javadoc:SE|package=javax.swing|javax/swing}} [[Java package|package]] hierarchy.
Development of Swing's successor, [[JavaFX]], started in 2005, and it was officially introduced two years later at JavaOne 2007.<ref>{{Cite web|url=https://jaxenter.com/jdk-11-javafx-separate-module-142186.html|title=JDK 11 update: JavaFX will be decoupled from the JDK}}</ref> JavaFX was open-sourced in 2011 and, in 2012, it became part of the Oracle JDK download. JavaFX is replacing Swing owing to several advantages, including being more lightweight, having [[Cascading Style Sheets|CSS]] styling, sleek design controls, and the use of [[FXML]] and Scene Builder.<ref>{{Cite web|url=https://opensourceforu.com/2017/07/developing-basic-gui-application-using-javafx-eclipse/|title=Developing a basic GUI application using JavaFX in Eclipse}}</ref> In 2018, JavaFX was made a part of the OpenJDK under the OpenJFX project to increase the pace of its development.<ref>{{Cite web|url=https://blogs.oracle.com/java-platform-group/the-future-of-javafx-and-other-java-client-roadmap-updates|title=The Future of JavaFX and Other Java Client Roadmap Updates|last=Smith|first=Donald|date=March 7, 2018}}</ref>
Members of the Java Client team that was responsible for Swing included Jeff Dinkins (manager), Georges Saab<ref>{{cite web |last1=Zakhour |first1=Sharon |title=Why is Swing Called Swing? |url=https://blogs.oracle.com/thejavatutorials/why-is-swing-called-swing |website=The Java Tutorials Blog |access-date=24 September 2020}}</ref>, Jim Graham, Rick Levenson, Tim Prinzing, Jonni Kanerva, Jeannette Hung, Tom Ball, and Amy Fowler (technical lead).<ref>{{cite web |last1=John |first1=Yu |title=Rich clients emerge as alternatives for Web applications |url=https://www.computerworld.com/article/2571634/rich-clients-emerge-as-alternatives-for-web-applications.html |website=ComputerWorld |access-date=24 September 2020}}</ref>
==Architecture==
Line 33 ⟶ 55:
This transposition and decoupling is not merely visual, and extends to Swing's management and application of its own OS-independent semantics for events fired within its component containment hierarchies. Generally speaking, the Swing architecture delegates the task of mapping the various flavors of OS GUI semantics onto a simple, but generalized, pattern to the AWT container. Building on that generalized platform, it establishes its own rich and complex GUI semantics in the form of the {{Javadoc:SE|javax/swing|JComponent}} model.
====Loosely coupled and MVC====
The Swing library makes heavy use of the [[model–view–controller]] software [[design pattern (computer science)|design pattern]],<ref>{{cite web |last1=Fowler |first1=Amy |url=https://www.oracle.com/java/technologies/a-swing-architecture.html |title=A Swing Architecture Overview |publisher=[[Sun Microsystems]] |access-date=2020-07-26}}</ref> which conceptually decouples the data being viewed from the user interface controls through which it is viewed. Because of this, most Swing components have associated ''models'' (which are specified in terms of Java [[interface (computer science)|interfaces]]), and the programmers can use various default implementations or provide their own. The framework provides default implementations of model interfaces for all of its concrete components. The typical use of the Swing framework does not require the creation of custom models, as the framework provides a set of default implementations that are transparently, by default, associated with the corresponding {{Javadoc:SE|javax/swing|JComponent}} child class in the Swing library. In general, only complex components, such as tables, trees and sometimes lists, may require the custom model implementations around the application-specific data structures. To get a good sense of the potential that the Swing architecture makes possible, consider the hypothetical situation where custom models for tables and lists are wrappers over [[Data Access Object|DAO]] and/or [[Ejb|EJB]] services.
Typically, Swing component model objects are responsible for providing a concise interface defining events fired, and accessible properties for the (conceptual) data model for use by the associated JComponent. Given that the overall MVC pattern is a loosely coupled collaborative object relationship pattern, the model provides the programmatic means for attaching event listeners to the data model object. Typically, these events are model centric (ex: a "row inserted" event in a table model) and are mapped by the JComponent [[Subclass (computer science)#Subclasses and superclasses|specialization]] into a meaningful event for the GUI component.
For example, the {{Javadoc:SE|javax/swing|JTable}} has a model called {{Javadoc:SE|javax/swing/table|TableModel}} that describes an interface for how a table would access tabular data. A default implementation of this operates on a two-dimensional [[Array data structure|array]].
The view component of a Swing JComponent is the object used to graphically represent the conceptual GUI control. A distinction of Swing, as a GUI framework, is in its reliance on programmatically rendered GUI controls (as opposed to the use of the native host OS's GUI controls). Prior to [[Java version history#Java SE 6 Update 10|Java 6 Update 10]], this distinction was a source of complications when mixing AWT controls, which use native controls, with Swing controls in a GUI (see [[Abstract Window Toolkit#Mixing AWT and Swing components|Mixing AWT and Swing components]]).
Finally, in terms of visual composition and management, Swing favors [[Layout manager|relative layouts]] (which specify the positional relationships between components) as opposed to absolute layouts (which specify the exact ___location and size of components). This bias towards "fluid"' visual ordering is due to its origins in the [[Java applet|applet]] operating environment that framed the design and development of the original Java GUI toolkit. (Conceptually, this view of the layout management is quite similar to that which informs the rendering of HTML content in browsers, and addresses the same set of concerns that motivated the former.)
===Relationship to AWT===
|