Spring_2008_Introduction_to_Graphical_User_Interfaces

Spring_2008_Introduction_to_Graphical_User_Interfaces - 1...

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

View Full Document Right Arrow Icon
Spring 2008 CS 1316: Representing Structure and Behavior John Munro 1 Introduction to Graphical User Interfaces (GUIs) Introduction to Graphical User Interfaces (GUIs) A graphical user interface, typically shortened to GUI (pronounced G-U-I or G-OO-E), is a simple form of user interface that allows people to interact with a computer. Usually a GUI in Java is composed of the window itself, a JFrame , which contains various panels, JPanel s. The JPanel s in turn can contain any number of components such as buttons and text fields. The relationship between the parts of a GUI where a JFrame contains JPanels. A JPanel contains components such as JButtons and JTextFields. Arranging the Components: Layout Managers You can control the layout of a JPanel by using the LayoutManager s. There are numerous layouts but the following are the primary ones we would like you to focus on: FlowLayout , typically just called flow when discussing LayoutManager s, is the default layout that simply adds content from left to right and centering the row within the panel. BorderLayout , or just border for short, allows you to specify what region of the panel NORTH, SOUTH, EAST, WEST, and CENTER to add the component. Remember each region can only contain one component. GridLayout , or simply grid , allows you to add components in a grid or table-like fashion, specifying the number of rows and columns when creating it. You can specify the layout of the panel in one of two ways: 1. Using the setLayout method. JPanel myFlowPanel = new JPanel(); JPanel myBorderPanel = new JPanel(); JPanel myGridPanel = new JPanel(); JFrame JPanel JPanel JPanel JButton JTextField
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
Spring 2008 CS 1316: Representing Structure and Behavior John Munro 2 Introduction to Graphical User Interfaces (GUIs)
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 ]}

Page1 / 4

Spring_2008_Introduction_to_Graphical_User_Interfaces - 1...

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