Week 8 Swing NetBeans GUI Builder PROG21478 Week 8 Swing NetBeans GUI Builder 2/21/2019 Wendi Jollymore, FAST
Swing A toolkit used to develop Uis (User Interfaces) GUI = Graphical User Interface Part of Java since version 1.2 Most classes in javax.swing package Many classes start with “J” E.g. JTextField, JLabel, JPanel, JButton 2/21/2019 Wendi Jollymore, FAST
AWT vs. Swing AWT = Abstract Windowing Toolkit For GUI development before Swing Heavy-weight components Not as platform-independent Relies on platform’s native code Affects reliability/efficiency of app Affects functionality/appearance E.g. button functionality/appearance limited by platform’s definition of a button Transparency, rounded corners, etc 2/21/2019 Wendi Jollymore, FAST
AWT vs. Swing Light-weight components Written in Java code Except JApplet, JDialog, JFrame Written in Java code Not platform’s native code Allows for extra functionality, appearance, etc. 2/21/2019 Wendi Jollymore, FAST
Swing API See Figure 12.1 in text, page 447 3 Categories of classes Component classes Container classes GUI Helper classes 2/21/2019 Wendi Jollymore, FAST
Component Classes Anything that can be displayed on the UI java.awt.Component Parent of all component classes, including containers javax.swing.JComponent Parent of Swing light-weight components 2/21/2019 Wendi Jollymore, FAST
Container Classes java.awt.Container Can hold instances of Component and Component children Top-Level containers Containers that can be displayed without being contained inside another container E.g. JFrame, JPanel Note that Container is a child of Component 2/21/2019 Wendi Jollymore, FAST
GUI Helper Classes java.awt package Graphics, Font, FontMetrics, Color, Dimension, LayoutManager, etc Used to describe properties of GUI components E.g. colours, fonts, layouts 2/21/2019 Wendi Jollymore, FAST
JFrame Class The main container that you’ll use The main window for your GUI You can then add other components: JLabel JTextField JButton Etc… 2/21/2019 Wendi Jollymore, FAST
NetBeans GUI Builder In Class Demo!! 2/21/2019 Wendi Jollymore, FAST