CS51 - Fall 2009 - Lecture 16

  • Test program 1
  • Description: <html> <pdf>
  • 3 short programs.
  • Basically lab assignments that you do without help.
  • Debugging tips
  • Comment out lines (this is related to the suggestion that you develop, implement, and test incrementally . . . you want to localize where the error might be)
  • Be aware of common errors (eg, == vs. =)
  • Use System.out.println, can use it to print out values of various types.
  • Ask someone else to take a look at your code!
  • JSlider
  • ColorSlider
  • uses ChangeListener
  • event-handling method is
          public void stateChanged(ChangeEvent evt) 
                
  • constructor takes min and max values, have to be integers
  • getValue() returns an integer
  • note also how JLabel is used
  • Keyboard input
  • JTextField
  • ColorMixer
  • hitting return triggers an ActionEvent
  • note use of the Integer class
  • Interesting
  • JTextArea
  • see TextApplet example in textbook