CIS3931 Intro to JAVA - PowerPoint PPT Presentation

About This Presentation
Title:

CIS3931 Intro to JAVA

Description:

GUI Programming Boxes, ToolBars, TextFields and glue. JToolBar ... See today's example code for usage. Examples ... See advancedgui.java ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 12
Provided by: UniformOfD
Learn more at: http://www.cs.fsu.edu
Category:
Tags: java | cis3931 | intro

less

Transcript and Presenter's Notes

Title: CIS3931 Intro to JAVA


1
CIS3931 - Intro to JAVA
  • Lecture Notes Set 12
  • 12-July-05
  • GUI Programming Boxes, ToolBars, TextFields and
    glue

2
JToolBar
  • GUI Container (you can store other GUI components
    inside of it)
  • Similar to a JMenuBar but doesnt have to be at
    the top of the screen (and can contain things
    other than menus)
  • Good for creating menus, text lines, etc.

3
Creating a JToolBar
  • //Create a toolbar (simple)
  • JToolBar sampleToolBar new JToolBar( )
  • //Create a toolbar (with name)
  • JToolBar sampleToolBar new JToolBar(Sample
    Bar)
  • //Setting a layout for the toolbar
  • sampleToolBar.setLayout(new BoxLayout(sampleToolBa
    r, BoxLayout.Y_AXIS))

4
JTextField
  • Editable horizontal line
  • Can have an action listener associated with it
  • Same as the URL line in Internet Explorer
  • http//java.sun.com/j2se/1.5.0/docs/api/javax/swin
    g/JTextField.html
  • Extention of JTextComponent

5
Creating a JTextField - Constructors
  • JTextField() Constructs a new TextField.
  • JTextField(Document doc, String text, int
    columns) Constructs a new JTextField that uses
    the given text storage model and the given number
    of columns.
  • JTextField(int columns) Constructs a new empty
    TextField with the specified number of columns.
  • JTextField(String text) Constructs a new
    TextField initialized with the specified text.
  • JTextField(String text, int columns) Constructs
    a new TextField initialized with the specified
    text and columns.

6
Creating a JTextField
  • //Create a JTextField
  • JTextfield sampleTextField new
    JTextField(sample text)

7
Box
  • GUI Container
  • Similar to a JToolBar, but more customizable
  • Best used when you want to group certain
    components together

8
Creating a Box
  • //Create a Box
  • Box sampleBox new Box()
  • //Create a Box and set the layout for it
  • Box sampleBox new Box(BoxLayout.Y_AXIS)

9
JLabel
  • GUI text component
  • Used to label a JTextField or other component
  • //Create a JLabel
  • JLabel sampleLabel new JLabel(Text)

10
Glue
  • Not a true glue (doesnt stick something
    somewhere)
  • A filler for GUI components
  • Used to create space between components
  • By default, most layouts push components up
    against each other
  • See todays example code for usage

11
Examples
  • See advancedgui.java
Write a Comment
User Comments (0)
About PowerShow.com