Standard GUI programming

posted by: Ms. Martin 22 October 2009 No Comment

The DrawingPanel class we’ve been using for Graphics was developed by UW and is non-standard.  There are a number of good reasons to use it rather than the standard Java tools and as you go through some of the resources I list, I encourage you to think about why I’ve made that decision.  What’s different about DrawingPanel and Swing, a set of built-in Java graphics components?

Here’s what I’d like for you to do.  I’ve uploaded two short Swing-based programs: GUIWindow.java and ColorPanel.java.  You’ll notice that while GUIWindow does run and produce a window with four rectangles, ColorPanel won’t run on its own.  Looking at GUIWindow, I want you to write a class called TargetWindow with only a main method which displays the target.  Notice that the target code itself is very similar to what you did using the DrawingPanel.

A lot of the code is not going to make very much sense at first, but that’s totally ok.  Pattern-matching is a perfectly acceptable way to start learning to work in a new environment.  Copy and paste pieces from GUIWindow into your new class and try to figure out where to use your ColorPanel.

If you’re interested in understanding more about Swing, I recommend going through a tutorial.  Again, don’t worry too much about understanding all the details and focus instead on experimentation.

1 Star2 Stars3 Stars4 Stars5 Stars (8 votes, average: 2.50 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>