Intro to Swing Components in Java
Summary:
This text provides notes on various Swing components in Java, including the differences between AWT and Swing, and covers components like JButton, JTextField, JComboBox, JTabbedPane, JScrollPane, JTree, JTable, JProgressBar, and tooltips. It also explains the use of layout managers like FlowLayout, BorderLayout, GridLayout, CardLayout, and GridBagLayout for organizing components in a container. The text describes how to create and customize Swing components and provides examples of their constructors and methods.
Excerpt:
Intro to Swing Components in Java
Advanced Java Notes
1.1 Component, Container, Window, Frame, Panel
➢ AWTEventMulticaster: Dispatches events to multiple listeners.
➢ Canvas: A blank, semantics-free window.
➢ Container : A subclass of Components that can hold other components.
➢ Cursor: Encapsulates a bitmapped cursor.
➢ Dialog : Creates a dialogue window.
➢ Dimension: Specifies the dimensions of an object. The width is stored in width, and the height is stored in height.
➢ Event: Encapsulates events.
➢ EventQueue: Queues events.
➢ FileDialog -: Creates a window from which a file can be selected.
➢ Font: Encapsulates a type font.
➢ FontMetrics: Encapsulates various information related to a font. This information helps you display text in a window
➢ Panel The simplest concrete subclass of Container.
➢ Component is an abstract class
➢ A Component object is responsible for remembering the current foreground and background colours and the currently selected text font.
➢ A container is responsible for laying out (that is, positioning) any components that it contains. It does this through the use of various layout managers

Advanced Java Notes
1.2 AWT Components and Layout Managers
➢ AWT – Abstract Windowing ToolKit
➢ Buttons in AWT are also called as Push Buttons
➢ Add() method is defined by container
➢ Remove() and RemoveAll() are the two methods defined by container. Remove(Component obj) method is used to remove a control of specified Component obj. And RemoveAll () is used to Remove the controls of all components.
➢ Label is Passive Component.
➢ Label Constructors:
• Label( ) throws HeadlessException Example – Label();
• Label(String str) throws HeadlessException Example – Label (“Aneesh”);
• Label(String str, int how) throws Headless Exception Example – Label (“Aneesh”, Label.LEFT)
Reviews