tags:

views:

158

answers:

2

The BasicArrowButton is a class is part of the Java SE. The BasicArrowButton Displays a Single Arrow Head in a specified direction. I want to override the class, preserving the existing methods but having the Basic Arrow Button display a double arrowhead instead of a single arrowhead. For Example See the following URL www.tiresias.org/images/ff.jpg. All I'm looking to do is to change the way this icon is drawn.

Thank you,

+1  A: 

Simple.

Subclass BasicArrowButton and override the paint() method and simply draw the image mentioned in your question (ff.jpg or any other image) by using g.drawImage().

Note you may need to copy ff.jpg in to your project and load it.

Note: For this you have to create a new class and use it. You cannot change the exisiting behaviour of BasicArrowButton because it does not use a UI delegate.

Suraj Chandran
+6  A: 

Hi, subclass BasicArrowButton and override paintTriangle. You can try recalling BasicArrowButton's paintTriangle method twice to get the triangles. For example:

public static class Bidriectional extends BasicArrowButton {
  private static final long serialVersionUID = 1L;

  public Bidriectional() {
   // This does not matter, we'll override it anyways.
   super(SwingConstants.NORTH);
  }

  @Override
  public void paintTriangle(Graphics g, int x, int y, int size,
    int direction, boolean isEnabled) {

   super.paintTriangle(g, x - (size / 2), y, size, SwingConstants.EAST, isEnabled);
   super.paintTriangle(g, x + (size / 2), y, size, SwingConstants.EAST, isEnabled);
  }
 }

Should give you a button looking something like this:

screenshot

Klarth
This is absolutely perfect. It is exactly what I need.Thank you so much!
Elliott