I am extending the JButton function so as to automate a couple of things, so I have only added this function:
public void addButton(Container container, int left, int top, int width, int height)
{
this.setBounds(left, top, width, height);
this.setSize(width, height);
container.add(this);
this.repaint();
}
and I am running this code in my pannel:
buttonLeft = new extendedButton("Left");
buttonMiddle = new extendedButton("Middle");
buttonRight = new extendedButton("Right");
Insets inset = this.getInsets();
setLayout(null);
Container c = getContentPane();
buttonLeft.addButton(c, inset.left, inset.top, 150, 50);
buttonMiddle.addButton(c, inset.left + buttonLeft.WIDTH, inset.top, 150, 50);
buttonRight.addButton(c, inset.left + buttonLeft.WIDTH + buttonRight.WIDTH, inset.top, 150, 50);
however, though I expect the buttons to appear one next to the other, they seem to appear one on top of the other and one pixel to the right. If however I replace the .WIDTH parameter with 150, it works as expected, any clues as to why .WIDTH denies to give the value I have set? I am not using a layout, I gave it null as a parameter.