Border Layout & flow layout

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

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. DiFerent layout managers arrange widgets diFerently. 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 J±rame. 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 ²ve areas: NORTH, WEST, SOUTH, EAST, and CENTER. The BorderLayout constructors are: ±igure 1: BorderLayout 1
Background image of page 1

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

View Full DocumentRight 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 speciFed by one of the constants BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, or BorderLayout.CENTER If no region is speciFed, a component is placed in the center region. Only one component can be placed in a region and components are resized to Ft the region. A button is a member of the JButton class. Three constructors are: JButton() ,
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.

Page1 / 7

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online