{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Grid layout & no layout

Grid layout & no layout - CSc 2700 Lecture 8 Grid...

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

View Full Document Right Arrow Icon
CSc 2700: Lecture # 8 Grid Layout & A Frame Without a Layout September 23, 2008 1 Grid Layout The GridLayout manager arranges the components in a table or grid of spec- ified dimensions, left to right, top to bottom, row by row. The constructors of GridLayout are: GridLayout(int rows, int cols) where rows and cols specify the number of rows and columns in the grid. GridLayout(int rows, int columns, int horizontalSpace, int verticalSpace) where rows and columns specify the number of rows and columns in the grid and horizontalSpace and verticalSpace are the horizontal and vertical gaps between components. GridLayout() creates a grid with one column for each component in a single row. Program # 1 uses GridLayout rather than FlowLayout to place 26 alphabet buttons in a frame 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
Program 1. import java.awt.*; import javax.swing.*; import java.util.*; public class GridAlphabetButtons extends JFrame { public GridAlphabetButtons (int width, int height) // two argument constructor { // width and height are frame dimensions
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 ]}