CS 106A Lecture Notes - Lecture 11: Window Screen, Fahrenheit, Graphical User Interface

57 views5 pages

Document Summary

Lecture notes graphical user interface part 2: review actionlisteners(); public void actionperformed(actionevent e){ string cmd = e. getactioncommand (); //cmd now is name of button: either get name of button or button itself, get name of button e. getactioncommand(), get button itself e. getscource(), old way of checking button (through name) Jbutton hi = new jbutton( hi ) public void actionperformed(actionevent e){ string cmd = e. getactioncommand(); if(cmd. equals( hi )): new way with actual object. Jbutton hi = new jbutton( hi ) public void actionperformed(actionevent e){ string cmd = e. getactioncommand(); if(e. getsource == hi): example of new way, use instance variable hibutton . Public void init(){ hibutton = new jbutton( hi ); add(hibutton, south); addactionlisteners(); public void actionperformed(actionevent e){ if(hibutton == e. getsource()){ println( hello there ): textfields, same pattern every time. Initialize new jtextfield(size) a. i. a. ii. setactioncommand( name ) a. iii. addactionlisteners(this): container that holds text, usually instance variable. Add(new jlabel( name ), south); namefield = new jtextfield(50); namefield. setactioncommand( go );

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents