Unit 1 - Abstract Window Toolkit (AWT).pdf
Document Details
Uploaded by EnrapturedSard6364
Tags
Full Transcript
Advance 22517 Java Programming Unit 1 - Abstract Window Toolkit (AWT) 1.4 Layou...
Advance 22517 Java Programming Unit 1 - Abstract Window Toolkit (AWT) 1.4 Layout Managers - The LayoutManagers are used to arrange components in a particular manner. The Java LayoutManagers facilitate us to control the positioning and size of the components in GUI forms. LayoutManager is an interface that is implemented by all the classes of layout managers. FlowLayout (java.awt.FlowLayout) - The Java FlowLayout class is used to arrange the components in a line, one after another (in a flow). It is the default layout of the applet or panel. Fields of FlowLayout public static final int LEFT public static final int RIGHT public static final int CENTER public static final int LEADING public static final int TRAILING Constructors FlowLayout() - creates a flow layout with centered alignment and a default 5 unit horizontal and vertical gap. FlowLayout(int align) - creates a flow layout with the given alignment and a default 5 unit horizontal and vertical gap. FlowLayout(int align, int hgap, int vgap) - creates a flow layout with the given alignment and the given horizontal and vertical gap. BorderLayout (java.awt.BorderLayout) - The BorderLayout is used to arrange the components in five regions: north, south, east, west, and center. Each region (area) may contain one component only. It is the default layout of a frame or window. Fields of BorderLayout public static final int NORTH public static final int SOUTH public static final int EAST public static final int WEST public static final int CENTER Constructors BorderLayout() - creates a border layout but with no gaps between the components. Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material Advance 22517 Java Programming BorderLayout(int hgap, int vgap) - creates a border layout with the given horizontal and vertical gaps between the components. GridLayout (java.awt.GridLayout) - The Java GridLayout class is used to arrange the components in a rectangular grid. One component is displayed in each rectangle. Constructors GridLayout(): creates a grid layout with one column per component in a row. GridLayout(int rows, int columns): creates a grid layout with the given rows and columns but no gaps between the components. GridLayout(int rows, int columns, int hgap, int vgap): creates a grid layout with the given rows and columns along with given horizontal and vertical gaps. GridBagLayout - The Java GridBagLayout class is used to align components vertically, horizontally or along their baseline. Constructor GridBagLayout(): The parameterless constructor is used to create a grid bag layout manager. CardLayout - The Java CardLayout class manages the components in such a manner that only one component is visible at a time. It treats each component as a card that is why it is known as CardLayout. Constructor Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material Advance 22517 Java Programming CardLayout(): creates a card layout with zero horizontal and vertical gap. CardLayout(int hgap, int vgap): creates a card layout with the given horizontal and vertical gap. Methods of CardLayout Class public void next(Container parent): is used to flip to the next card of the given container. public void previous(Container parent): is used to flip to the previous card of the given container. public void first(Container parent): is used to flip to the first card of the given container. public void last(Container parent): is used to flip to the last card of the given container. public void show(Container parent, String name): is used to flip to the specified card with the given name. MenuItem and Menu public class MenuItem extends MenuComponent implements Accessible public class Menu extends MenuItem implements MenuContainer, Accessible Dialog public class Dialog extends Window Constructor Dialog(Dialog owner) - Constructs an initially invisible, modeless Dialog with the specified owner Dialog and an empty title. Dialog(Dialog owner, String title) - Constructs an initially invisible, modeless Dialog with the specified owner Dialog and title. Dialog(Dialog owner, String title, boolean modal) - Constructs an initially invisible Dialog with the specified owner Dialog, title, and modality. Dialog(Frame owner)- Constructs an initially invisible, modeless Dialog with the specified owner Frame and an empty title. Dialog(Frame owner, boolean modal)- Constructs an initially invisible Dialog with the specified owner Frame and modality and an empty title. Dialog(Frame owner, String title) - Constructs an initially invisible, modeless Dialog with the specified owner Frame and title. Dialog(Frame owner, String title, boolean modal) - Constructs an initially invisible Dialog with the specified owner Frame, title and modality. FileDialog Constructor FileDialog(Dialog parent) - Creates a file dialog for loading a file. FileDialog(Dialog parent, String title) - Creates a file dialog window with the specified title for loading a file. FileDialog(Dialog parent, String title, int mode) - Creates a file dialog window with the specified title for loading or saving a file. FileDialog(Frame parent) - Creates a file dialog for loading a file. FileDialog(Frame parent, String title) - Creates a file dialog window with the specified title for loading a file. Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material Advance 22517 Java Programming FileDialog(Frame parent, String title, int mode) - Creates a file dialog window with the specified title for loading or saving a file. Mode static int LOAD -- This constant value indicates that the purpose of the file dialog window is to locate a file from which to read. static int SAVE -- This constant value indicates that the purpose of the file dialog window is to locate a file to which to write. Free Study Material Buy Ty Diploma Buy Sy Diploma Whatsapp Group for Study Material