DOC PREVIEW
UMD CMSC 132 - GUI Elements in Java

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

GUI Elements in Java Nelson Padua Perez Chau Wen Tseng Department of Computer Science University of Maryland College Park 1 GUI Elements Component items displayed widgets Container region containing widgets Layout arrangement of container Event interactions for GUI 2 1 GUI Elements Component Definition Actual items widgets user sees in GUI Examples Labels fixed text Text areas for entering text Buttons Checkboxes Tables Menus Toolbars Etc 3 GUI Elements Container Definition Abstractions occupying space in GUI Properties Usually contain one or more widgets Can be nested in other containers Example Window containing 1 menu component 3 buttons component 2 windows container 4 2 GUI Elements Layout Definition Arrangement of widgets in container Layout specification Logical terms 2nd row 1st column left Preferred approach Actual coordinates 100 pixels 5 inches Can be too rigid limited to certain window sizes Layout manager Entity translating layout specifications into actual coordinates at runtime depending on conditions 5 Example Java Layout Managers GridLayout Lays out components in a grid of user specified size BorderLayout Designates portions of the container as North South East West and Center CardLayout Adds components one on top of another GridBagLayout Customizable manager that can use rows and columns of varying lengths 6 3 GUI Elements Events Definition Action or condition occurring outside normal flow of control of program Examples Mouse clicks Keyboard input Menu selections Window actions 7 Java GUI Classes AWT Abstract Window Toolkit java awt Old GUI framework for Java Java 1 1 Some reliance on native code counterparts Platform independence problems Swing javax swing New GUI framework first introduced in Java 1 2 Includes AWT features plus many enhancements Pure Java components no reliance on native code Pluggable look and feel architecture 8 4 JFrame Hierarchy Several super classes and well as implemented interfaces Many many member methods including inherited methods that allow for operations such as resizing setting properties adding components etc Other top level containers JDialog dialog boxes JApplet web applets JWindow stripped down JFrame no title bar or window buttons Object Component Container Window Frame JFrame 9 Java GUI Components Examples JFrame JTextfield Jlabel Button JList JComboBox Menu Combo Panes Indicators Dialog boxes JFileChooser Color chooser JTable JTree 10 5 Examples Illustrates how to create a JFrame and a JPanel Illustrates how we can set a call back to take care of certain mouse events those associated with MouseListener Example package example1 of code distribution Example package example2 Shows how we can put all together in one class Example package example3 Shows how two layout managers organize components 11 JFrame Structure Most things go into content pane getContentPane glassPane layeredPane rootPane JFrame Use glassPane for pop up menus some animations Methods getRootPane getLayeredPane getContentPane getGlassPane Can set Pane explicitly LayeredPane manages optional JMenuBar LayeredPane contains contentPane 12 6 JFrame 13 JTextField and JLabel 14 7 Buttons Toolbar 15 JList and JComboBox 16 8 Menu 17 Panels and Panes Tabbed Pane Split Pane Scroll Pane 18 9 Various Indicators Spinner Slider Progress Bar 19 A Dialog Box 20 10 JFileChooser 21 Color Chooser 22 11 Jtable and JTree 23 Text Fields 24 12


View Full Document

UMD CMSC 132 - GUI Elements in Java

Documents in this Course
Notes

Notes

8 pages

Recursion

Recursion

12 pages

Sorting

Sorting

31 pages

HTML

HTML

7 pages

Trees

Trees

19 pages

HTML

HTML

18 pages

Trees

Trees

19 pages

Honors

Honors

19 pages

Lecture 1

Lecture 1

11 pages

Quiz #3

Quiz #3

2 pages

Hashing

Hashing

21 pages

Load more
Loading Unlocking...
Login

Join to view GUI Elements in Java and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view GUI Elements in Java and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?