CS51 - Fall 2009 - Lecture 14

  • 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!
  • Keyboard input
  • KeyDemo
  • KeyListener interface requires 3 methods: keyPressed, keyTyped, keyReleased
  • in general rely on keyPressed to determine which key was pressed
  • basic GUIs
  • create the gui item and initialize it if necessary
  • add the item to the content pane of the WindowController
  • validate
  • for an example, see ComboBoxDrawingProgram