Gui Examples


There are 8 examples below. The first simply opens a window (JFrame). The last one has buttons and panels and listens to button clicks in order to do something. Each successive example adds one or two new features to more clearly demonstrate what each one does.

Show1.java -- open a window frame
Show2.java -- attach a window closing listener, make a title
Show3.java -- different way of attaching buttons
Show4.java -- attach a listener to button (use ActionListener)
Show5.java -- attach listeners to 2 buttons; test to tell which
Show6.java -- add Jpanel to JFrame with background color
Show7.java -- change the color, draw a line, repaint
Show8.java -- change the position of the line drawn too