120 likes | 128 Views
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.
E N D
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
Pig program…non-gui version. • Begin discussion of GUI’s. Chapter 7 and 12.
GUI • AWT • Inheritance – brief discussion • Component classes, container classes (see next slide) • Applets • Quick look at AtmScreen
Component Checkbox Choice Button Canvas Container Label TextComponent Window Panel TextField TestArea Frame Applet Figure 7.3 Some subclasses of Component
Layouts - Flow Layout • ButtonFlow.java • Use an object derived from Canvas (AWT), • Subclass it • Override paint method • ButtonCanvas.java
Making Buttons Work • Events, ActionEvents, Handlers • ButtonPress • ButtonCanvasPress
TextField • TextField object • Must use String for onscreen display so use Integer wrapper class for conversion • EnterPrice
Other Layouts • Border Layout • Border.java • BorderPanel.java Use Panels to add levels of organization on the screen. • Grid Layout • Grid.java
Other Controls and Layouts • Skip for now to talk about Swing classes
Swing • Later improvement on AWT • Java based, rather than being based on native windowing. • All components are derived from Container class.
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
First Examples • ButtonJComponent • ButtonJPanelPink • GrowthFrameSwing – stand alone window • BasicWindow - stripped down version