Monthly Archives: October 2004

div’s to fill the whole screen

When working with a combination of divs, and tables, I have ended up beating my head against getting a div to go all the way to the end of where the page scrolls to. This is useful to make the familiar navigator bar on the left side go all the way to the end of the page.

The way to do it is to make sure that the html and body tags actually go to the bottom. The thought being that something will only go to the end if it’s container goes to the end. (In some bizarre land I am sure this makes sense).

To do this, simply put this into the stylesheet:
html,body {
height: 100%;

Information courtesy of google and Web Master world

code snippit to Find the active Window in Swing

To find the active Window(be it a frame or a dialog) in a java swing application you can use the following recursive method:

Window getSelectedWindow(Window[] windows) {

    Window result = null;

    for (int i = 0; i < windows.length; i++) {

        Window window = windows[i];

        if (window.isActive()) {

            result = window;

        } else {

            Window[] ownedWindows = window.getOwnedWindows();

            if (ownedWindows != null) {

                result = getSelectedWindow(ownedWindows);




    return result;


For the first call, pass in all the frames for the application with Frame.getFrames().

Comment spam (Off Topic)

I am about to update my stratgegy to fight comment spam…..

I have been working on the benevolant approach of using a combination of mt-blacklist, and manual deletion of the ones that get through…. but after having to delete another round of sick disgusting comments I have had enough.

I am now changing my configuration to require registration before commenting. I apolagise for the pain this may cause, but the evil world that we are in makes it mandatory.

Dynamic display with JGoodies

The basics of using the JGoodies Forms package are really well described in their excellent Whitepaper, however, this doesn’t really cover how to add and remove elements dyamically.

The recommended builder approach works well for constructing the first display of the page, but updates need a little bit more work. When updating the display I have fallen back to updating the panel more directly.

This involves two steps, first removing the components from the swing container, then adding the new components, specifying FormLayout constraints.

The remove componets process is:
go to the container,
call getComponents,
iterate until a known component is reached.

All components after this are removed using remove.

Each new component to add, has the following process applied.

First add a row to the layout,
layout.appendRow(new RowSpec(“pref”));

then add the label, and field.
panel.add(label, constraints.xy(row, 1))
panel.add(field, constraints.xy(row, 3))

The constraints object is an instance of the JGoodies CellConstraints class.
layout is a JGoodies FormLayout. The rowSpec specifies how the row is to be layed out (here we are respecting the preference of the field).

Using this approach gives well ordered look. The dynamic section of the form is seperated from the non-dynamic, but doesn’t look like it was tacked on.

The first test method

When writing a class that will slot into a framework, I often know that I will need it to implement an interface. The quickest way of getting a test writen is to do this:

public void testSaveActionIsAnAbstractAction() throws Exception {

I then don’t need to type any of this…..

public class ISMSaveAction extends AbstractAction{
public void actionPerformed(ActionEvent e) {
throw new NoSuchMethodError();

and my next test is obvious.

This test is not to replace the tests that actually test real behaviour. It is a nice way to start getting your code writen, and helps keep the flow of red/green/refactor going.