Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS221 © 2007 Ray S. Babcock Layout, Components, & Data Entry Appendix C.3-C.5.

Similar presentations


Presentation on theme: "CS221 © 2007 Ray S. Babcock Layout, Components, & Data Entry Appendix C.3-C.5."— Presentation transcript:

1 CS221 © 2007 Ray S. Babcock Layout, Components, & Data Entry Appendix C.3-C.5

2 CS221 © 2007 Ray S. Babcock Layout Managers  BorderLayout  Arranges objects in five areas of the container.  FlowLayout  Arranges objects in left-to-right order.  BoxLayout  Arranges objects in a single row or column.  GridLayout  Arranges objects in a two-dimensional grid.  BorderLayout  Arranges objects in five areas of the container.  FlowLayout  Arranges objects in left-to-right order.  BoxLayout  Arranges objects in a single row or column.  GridLayout  Arranges objects in a two-dimensional grid.

3 CS221 © 2007 Ray S. Babcock BorderLayout  Default layout for JFrame’s content pane.  5 areas (N,S,E,W,Center)  Don’t have to fill out all areas.  See Listing and Example.  Be sure to use Java reference.  Java Reference Document Java Reference Document  Remember to look up class hierarchy.  Use Index.  Find setBorder?  Constants.  Default layout for JFrame’s content pane.  5 areas (N,S,E,W,Center)  Don’t have to fill out all areas.  See Listing and Example.  Be sure to use Java reference.  Java Reference Document Java Reference Document  Remember to look up class hierarchy.  Use Index.  Find setBorder?  Constants.

4 CS221 © 2007 Ray S. Babcock FlowLayout  Left to Right until maximum width.  Dimension for array size.  PreferredSize (20, 20).  Show resize of window.  Last line centered if not full.  Use setAlignment to change order.  See Listing and Example.  Left to Right until maximum width.  Dimension for array size.  PreferredSize (20, 20).  Show resize of window.  Last line centered if not full.  Use setAlignment to change order.  See Listing and Example.

5 CS221 © 2007 Ray S. Babcock BoxLayout  Horizontal or Vertical arrangement.  BoxLayout.X_AXIS  BozLayout.Y_AXIS  Components don’t wrap.  See Listing and Example.  What’s missing from this code?  (Hint: related to buttons.)  Horizontal or Vertical arrangement.  BoxLayout.X_AXIS  BozLayout.Y_AXIS  Components don’t wrap.  See Listing and Example.  What’s missing from this code?  (Hint: related to buttons.)

6 CS221 © 2007 Ray S. Babcock GridLayout  Rectangular grid.  Fixed Size (set by setLayout(new GridLayout( 5,10) )  5 rows and 10 columns.  See Listing and Example.  Note Integer.toString (conversion method)  Factories described on page 183.  Rectangular grid.  Fixed Size (set by setLayout(new GridLayout( 5,10) )  5 rows and 10 columns.  See Listing and Example.  Note Integer.toString (conversion method)  Factories described on page 183.

7 CS221 © 2007 Ray S. Babcock Combining Layouts  Lab #3 (Programming #2, page 785)

8 CS221 © 2007 Ray S. Babcock Components for Data Entry  So what does a good GUI do?  Enable the user to provide input data to an application.  Enable the user to control the action of the application.  Display information or results to the user.  Are there any “bad” Guis?  Web Pages That Suck Poor DesignPoor Design  Interface Hall Of Shame ShameShame  So what does a good GUI do?  Enable the user to provide input data to an application.  Enable the user to control the action of the application.  Display information or results to the user.  Are there any “bad” Guis?  Web Pages That Suck Poor DesignPoor Design  Interface Hall Of Shame ShameShame

9 CS221 © 2007 Ray S. Babcock CheckBoxDemo  Multiple selections possible.  Check mark shows selection.  See Listing and Example.  Note listeners.  Multiple selections possible.  Check mark shows selection.  See Listing and Example.  Note listeners.

10 CS221 © 2007 Ray S. Babcock RadioButtonDemo  Only one selection possible.  Old time “radio buttons”, press one and it resets the others.  See Listing and Example.  Note selections.length used to control number of buttons.  Also, note the loop to define buttons.  Only one selection possible.  Old time “radio buttons”, press one and it resets the others.  See Listing and Example.  Note selections.length used to control number of buttons.  Also, note the loop to define buttons.

11 CS221 © 2007 Ray S. Babcock ComboBoxDemo  Selections shown by text.  Drop-down list.  See Listing and Example  Note, no loop.  Selections shown by text.  Drop-down list.  See Listing and Example  Note, no loop.

12 CS221 © 2007 Ray S. Babcock TextFieldDemo  Label and field to type in.  See Listing and Example.  Note NumberEntered uses an exception.  Label and field to type in.  See Listing and Example.  Note NumberEntered uses an exception.

13 CS221 © 2007 Ray S. Babcock Example Data Entry in a GUI  VolumeConverterGUI  Fairly complicated constructor.  Enter in one field, output in the other.  Notice how the gui is built-up in layers.  JFrame’s content pane set to a 2x2 grid.  The grid contains labels and text boxes.  Two files to look at.  See Listing and Example.  VolumeConverterGUI  Fairly complicated constructor.  Enter in one field, output in the other.  Notice how the gui is built-up in layers.  JFrame’s content pane set to a 2x2 grid.  The grid contains labels and text boxes.  Two files to look at.  See Listing and Example.

14 CS221 © 2007 Ray S. Babcock CurrencyDemo  An example of querrying “where am I”?  Using the Java locale.  An example of querrying “where am I”?  Using the Java locale.


Download ppt "CS221 © 2007 Ray S. Babcock Layout, Components, & Data Entry Appendix C.3-C.5."

Similar presentations


Ads by Google