1 / 12

First Program

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.

patsy
Download Presentation

First Program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 program…non-gui version. • Begin discussion of GUI’s. 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 Abstract Button JPanel JList 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

More Related