{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Border Layout & flow layout

Border Layout & flow layout - CSc 2700 Lecture 7 Border...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSc 2700: Lecture # 7 Border Layout September 18, 2008 1 Introduction To add components to a frame, Java provides layout managers. Each layout manager is an object that determines how components are placed in a frame. Different layout managers arrange widgets differently. In this lecture we will discuss the border layout manager. In subsequent lectures, we will discuss additional layout managers. 2 Border Layout BorderLayout is the default layout manager for JFrame. If you do not in- stantiate a layout manager for a frame, components are placed in a frame using the BorderLayout layout manager. The BorderLayout manager divides a frame into five areas: NORTH, WEST, SOUTH, EAST, and CENTER. The BorderLayout constructors are: Figure 1: BorderLayout 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
BorderLayout() BorderLayout(int horizGap, int vertGap) where horizGap and vertGap specify horizontal and vertical space, in pixels, between components. The method add(Component c, int region) places a component into a container. The parameter region is specified by one of the constants BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, or BorderLayout.CENTER If no region is specified, a component is placed in the center region. Only one component can be placed in a region and components are resized to fit the region. A button is a member of the JButton class. Three constructors
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}