





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Swing Tutorial. 1. Introduction. • Swing – A set of GUI classes. • Part of the Java's standard library. • Much better than the previous library: AWT.
Typology: Lecture notes
Uploaded on 09/27/2022
1 / 9
This page cannot be seen from the preview
Don't miss anything!






1
import javax.swing.*; import java.awt.BorderLayout; public class First { public static void main(String[] args) { JFrame frame = new JFrame("My First Frame"); // operation to do when the window is closed. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(new JLabel("I Love Swing"), BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } } 4
9
10
13
import javax.swing.*; import java.awt.BorderLayout; public class First { public static void main(String[] args) { JFrame frame = new JFrame("My First Frame"); // operation to do when the window is closed. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(new JLabel("I Love Swing"), BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } } 14 Create a frame Create a text label Add the label to the content pane Choose the border layout Specify CENTER as the layout position