I want to replace some methods in DefaultArrowButton and JComboBox to make them visual changes (change everything). Some methods are private. I can't override them. Next problem is lack of possibility to call private members of superclass.
I am sure I have wrong idea to achieve my goal. I putted some code below which is wrong because I can't acces private members from child Class. Also I didn't insert all long code just two methods which show everything I want to show (+ constructors):
public class DefaultArrowButton extends BasicArrowButton {
public DefaultArrowButton(int direction) {
super(direction);
setBackground(HFColors.BLUE);
setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
}
public DefaultArrowButton(int direction, Color background, Color shadow,
Color darkShadow, Color highlight) {
super(direction, background, shadow, darkShadow, highlight);
}
public void paintTriangle(Graphics g, int x, int y, int size, int direction,
boolean isEnabled)
{
Color savedColor = g.getColor();
switch (direction)
{
case NORTH:
paintTriangleNorth(g, x, y, size, isEnabled);
break;
case SOUTH:
paintTriangleSouth(g, x, y, size, isEnabled);
break;
case LEFT:
case WEST:
paintTriangleWest(g, x, y, size, isEnabled);
break;
case RIGHT:
case EAST:
paintTriangleEast(g, x, y, size, isEnabled);
break;
}
g.setColor(savedColor);
}
private void paintTriangleSouth(Graphics g, int x, int y, int size,
boolean isEnabled) {
int tipX = x + (size - 2) / 2;
int tipY = y + (size - 1);
int baseX1 = tipX - (size - 1);
int baseX2 = tipX + (size - 1);
int baseY = y;
Polygon triangle = new Polygon();
triangle.addPoint(tipX, tipY);
triangle.addPoint(baseX1, baseY);
triangle.addPoint(baseX2, baseY);
if (isEnabled)
{
g.setColor(Color.CYAN);
g.fillPolygon(triangle);
g.drawPolygon(triangle);
} else
{
g.setColor(Color.CYAN);
g.fillPolygon(triangle);
g.drawPolygon(triangle);
}
}
}
What should I do instead?