class HexArrayField {
/**
* Constructs a new field of 0 cells.
*/
public HexArrayField() {
super(new FlowLayout(FlowLayout.LEFT,0,0));
setFont(FONT);
setForeground(FOREGROUND);
lcLbl = new JLabel("lc: ");
lcLbl.setEnabled(false);
lcHexLbl = new HexField(1);
lcHexLbl.setEditable(false);
lcHexLbl.setEnabled(false);
smallerButton = new BasicArrowButton(BasicArrowButton.WEST);
smallerButton.addActionListener(this);
largerButton = new BasicArrowButton(BasicArrowButton.EAST);
largerButton.addActionListener(this);
add(lcLbl);
add(lcHexLbl);
add(smallerButton);
add(largerButton);
this.length = 0;
}
}
class HexArrayField {
/**
* Removes the rightmost cell.
*/
public void removeCell() {
if (length > 0) {
/* (1) lcLbl, (2) lcHexLbl, (3) smallerButton, (4) largerButton. */
length--;
lcHexLbl.setValue((byte)length);
remove(length + 4);
} else {
length = 0;
lcHexLbl.setValue((byte)length);
}
lcLbl.setEnabled(length > 0);
lcHexLbl.setEnabled(length > 0);
}
}
|