public void draw(GraphicsWrapper gw) { // draw border gw.setColor(0, 0, 0); gw.drawRect(x0, y0, width, height); for (PaletteButton b : buttons) { b.draw(x0, y0, gw); } }
// returns -1 if no button contains the given point public int indexOfButtonContainingTheGivenPoint(float x, float y) { for (int j = 0; j < buttons.size(); ++j) { PaletteButton b = buttons.get(j); if (b.contains( x - x0, y - y0)) // the subtraction converts the coordinates to the palette's local coordinate // system return j; } return -1; }
public void paletteUserOver(PaletteButton button, boolean inside) { if (inside) { showStatus(button.name()); } else if (fSelectedToolButton != null) { showStatus(fSelectedToolButton.name()); } }
public void paint(Graphics g) { // selecting does not work as expected with JFC1.1 // see JavaBug: 4228035, 4233965 if (isSelected()) { paintSelected(g); } else { super.paint(g); } }