/ Programming II: Lecture
Layouts, Panes, Listeners etc.
-I. House Keeping
- Coursework 2 notes:
- The hard parts of the assignment should be:
- Just learning all the Java components (not that hard, just
- Putting all the pieces together.
- Basically, nothing should be hard in particular, it's just a
lot of practice, which is what you need.
- If you are really having trouble coding, spend time with the
tutors in lab!
- There's no reason that the tutors should ever be alone while
they are in lab.
- They get paid for being there.
- People last year were overly worried about CW2. I want to
address some possible falicies:
- Q: CW2 involves knowing and doing too many different things!
- A: CW2 only suggests doing a lot of things. You
only need to do 3 or 4 of them to get an excellent mark.
- Q: you need to already know Java to do well on CW2.
- A: No, you can learn enough to do well if you've been keeping
up with lectures & you have been putting the time you are supposed
to (about 7 hours a week) into the course work.
The reason there are so many different things you can do is that you
can pick which parts of the most recent content are most interesting to
you & try to get extra marks with them. Though some things
- Q: But it does help if you
already know how to do Java.
- A: Yes, and it helps your mark in Spanish if you're
already fluent in Spanish / go to Spain every summer.
the way it ought to be --- the whole point of assessing coursework is
to see if you know how to program, not to find out where you learned!
- Though that is one reason why MIT used to
teach people Scheme instead of a more popular language.
- Q: Well, I think CW2 is much too easy!
- A: The point isn't just to get marks.
- The main point is to learn. That's why you're here.
- If you build something cooler than you can get marks for,
you can always put it on your web page & show it off to potential
employers, your parents, or (geeky) dates.
- The most important thing for tackling a big problem like CW2 is
to develop the code iteratively.
about what you need to do & what you want to do.
- Figure out a piece you can do first, that you can test without
having gotten everything else working.
- Build that piece.
- Test that piece & fix it until it works.
- Now go back to step I.2.1!
- You'll have learned things about the problem and the
solution, so you want to think about the problem again before you
choose the next piece to do.
- Don't forget this is a double unit.
- Counts for twice as much as your other units.
- Should get twice as much of your time.
is an art. Practicing is the only way to get better.
- finish listeners if didn't last time
- Remember the kinds of things we saw when building the window
- Widgets (small components)
- Remind students what these are for!
- Now we're going to look at how to look up and find stuff that you
can use to build into your system. (except not about listeners,
go to yesterday's lecture to
see about them.
II. Containers &Panes
- This lecture is mostly out of the Java Tutorial, because that way
I got all the running components for free.
- This may seem like the laziest lecture of all time, but honest,
I spent a lot of time looking for better solutions & then deciding
what to show you after I decided how to show it...
- For you guys the tutorial for swing starts on http://java.sun.com/docs/books/tutorial/uiswing/,
but these links are for my laptop.
- Best to start here, show the path file:///Users/j2bryson/Documents/java%20tutorial%20Folder/uiswing/index.html
- Start with componenths --> visual introduction
- Top level containers
- skip applets, get them Tuesday
- dialogs --
- remind them they've seen one of the default ones at the top
they ran the code from the last lecture.
- show them everything on the run dialog demo, then show them
code for a few things.
- code is a couple screens past the demo, just before screen
shots, or through link.
- we'll be doing radio buttons etc. later, see how they work.
- Be sure to show modal stuff, leads to glass pane below...
- Frame --
- already saw basics yesterday,
- but show first & last set of methods
- diff exits, icon -- see notes too
- show & talk about the different panes. No longer sensible from this page!
- skip down to "special purpose containers"
- show pane drawing,
- explain glass pane again,
- go into layered panes, show demo
- go back up to GP containers
- skip panels until talk about layouts
- show scroll pane -- show demo
- show basic call to scroll pane at top - arg is another pane
- go down to show how scroll panes are themselves made of other
components -- you could really build your own.
- might want to
use scroll panes for problem set.
- show split pane demo
- offer tabbed pane demo, prob not
- cool thing is the dragging
- show basic demo,
- explain disabled / enabled concept
- tool tips
- can't always use glass pane! often some options make sense in
- e.g. can't edit or graph file before you've chosen it.
- show radio buttons / single option
- show check buttons / multiple options.
- emphasize these are universals
- show list
- maybe show demos (time?)
- show the selection model part!
- show combo box
- like radio buttons but takes less space
- editable one doesn't seem to work
- show slider
- not demo, just code is enough, right after first demo/picture
- demo is kind of cool if time -- stops you from giving wrong
answer, advances from right one
- for sure go down & show the stuff about models (remember
model, view controller?)
- text field
- go in and show the different types of text fields
- when done, click on formatted & show the example formats
- Wave at uneditable displays -- no time to really go in to it
& it's obviousl
- wave at most of interactive displays, but go into text
- go down to the table of types of text components,
- point out text panes are darn useful for coursework
- show demo
- got to go way up to where you had clicked on "using swing
components", then down two to layouts, visual guide
- for you folks:
- one they saw before was grid, probably the most boring
- most generally useful / quick is border
- need directions
- center expands to fit
- flow layout is really easy
- box layout is too,
- a lot like panels
- can make vertical boxes of horizontal panels, kind of like grid
- grid bag a bit more complicated, flexible
- spring layout for nice fancy things
- runnable demo is way down on 3rd one for some reason.
- talked about listeners quickly, then showed containers &
panes, components, layouts
- You should play with them & look at the documentation!
page author: Joanna Bryson
9 March 2006