First Program - PowerPoint PPT Presentation

About This Presentation
Title:

First Program

Description:

Component classes, container classes (see next ) Applets. Quick look at AtmScreen ... are derived from Container class. Container(AWT) JComponent. JLabel ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 13
Provided by: gene92
Category:

less

Transcript and Presenter's Notes

Title: First Program


1
First Program
  • Download the code for Rational
  • Create a TestRational class in a separate file.
  • Add the compareTo and the extra Constructor to
    the Rational class.
  • Modify TestRational to test the new additions.
  • Turn in your modified Rational.java and
    TestRational.java

2
  • Pig programnon-gui version.
  • Begin discussion of GUIs. Chapter 7 and 12.

3
GUI
  • AWT
  • Inheritance brief discussion
  • Component classes, container classes (see next
    slide)
  • Applets
  • Quick look at AtmScreen

4
Component
Checkbox
Choice
Button
Canvas
Container
Label
TextComponent
Window
Panel
TextField
TestArea
Frame
Applet
Figure 7.3 Some subclasses of Component
5
Layouts - Flow Layout
  • ButtonFlow.java
  • Use an object derived from Canvas (AWT),
  • Subclass it
  • Override paint method
  • ButtonCanvas.java

6
Making Buttons Work
  • Events, ActionEvents, Handlers
  • ButtonPress
  • ButtonCanvasPress

7
TextField
  • TextField object
  • Must use String for onscreen display so use
    Integer wrapper class for conversion
  • EnterPrice

8
Other Layouts
  • Border Layout
  • Border.java
  • BorderPanel.java
  • Use Panels to add levels of organization on the
    screen.
  • Grid Layout
  • Grid.java

9
Other Controls and Layouts
  • Skip for now to talk about Swing classes

10
Swing
  • Later improvement on AWT
  • Java based, rather than being based on native
    windowing.
  • All components are derived from Container class.

11
Container(AWT)
JComponent
JLabel
JList
JPanel
Abstract Button
JScroll Pane
JCombo Box
JMenu Bar
JOption Pane
JMenu Item
JButton
JToggle Button
JCheckBox
JRadioButton
Figure 12.1 Some Swing subclasses of JComponent
12
First Examples
  • ButtonJComponent
  • ButtonJPanelPink
  • GrowthFrameSwing stand alone window
  • BasicWindow - stripped down version
Write a Comment
User Comments (0)
About PowerShow.com