Java Programming/Swing
< Java Programming​(Redirected from Introduction to Programming in Java/Swing)
About Swing Swing library is an official Java GUI toolkit released by Sun Microsystems. Swing is a lightweight component and does not use the native API's of the OS. The main characteristics of the Swing toolkit:
Swing is no longer the latest GUI toolkit for use with Java, being replaced by JavaFX. However, it will remain included in Java for the forseeable future. For more information, see the JavaFX Frequently Asked Questions.
Java Swing first programs
A basic test application for Swing is as follows:
import javax.swing.JFrame; public class Test extends JFrame { public Test() { setSize(300, 200); setTitle("Test"); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { Test test = new Test(); test.setVisible(true); } }
The constructor contains three function calls. The first two set the size and title of the window. The third statement is used to terminate the application once the window is closed; by default, the program will keep running even though the main function finishes. This is a change from non-graphical Java applications.
Project: Introduction to Programming in Java
Previous: Introduction to Programming in Java/Arrays — Java Programming/Swing — Next:
Last edited on 2 August 2020, at 23:11
Content is available under CC BY-SA 3.0 unless otherwise noted.
Privacy policy
Terms of Use
 Home Random Log in  Settings  Donate  About Wikiversity  Disclaimers