MyIF interface development example - Musings

By Nicholas Duchon - March 16, 2012; Nov 11, 2017, Musings

one
Lines of code
Phase
Comments
25
MyIFa JApplet with JButton and ActionListener
Counts number of times button is pressed
56
MyIFb Named inner classes, colored buttons
29
MyIFc Anonymous inner class ActionListener connected to JButton
49
MyIFd MyRecord of 4 integers with toString method - inner class
contents of random record displayed as part of the JButton label
pressing the button creates a new MyRecord
71
MyIFe Scrolling TextArea used to display new MyRecord with each button press
95
MyIFf Each button press shows a display of 100 new MyRecord's
127
MyIFg JButton sorts on first column, natural order of MyRecord implementing Comparable
no generics
238
MyIFh Inner classes to sort on each of 4 fields of MyRecord
static Comparator classes defined and instantiated for each field
one Comparator (CompareFour) uses generics
232 MyIFk all Comparator's are generic, no -Xlint warnings
222 MyIFm use enum's to determine sorting order
MyButton class added to simplify definition and control of buttons
uses java.awt.Font

Lines of code
Phase
Comments
161
MyIFn
  • Take advantage of some stuff in JDK 8
    • lambda expressions to simplify event listeners
    • bifunctions to specify comparator functions for sorts
    • bifunctions as parameters to constructors, and instance variables.
  • extend JFrame rather than JApplet
169
Sort002
  • MyButton class added to simplify button definitions
201
Sort003
  • Uses :: method references
    • class / static method references
  • No longer uses generics
  • Slightly more informative interface
207
Sort004
  • Removes MyButton class
  • More use of :: method references
    • ActionEvent
    • Comparable (<MyRecord004>)
176
Sort005
  • Uses (a,b) -> Comparables on the 4 columns
A:
B:
C:

D:

E:
F:

G:

H:

K:

M:
N:
Sort002:

Sort003:
Sort004:

Sort005: