Navigating a Class Button with a Basic Arrow in Java

BasicArrowButton is a class that is part of Java SE. BasicArrowButton displays a single arrow in the specified direction. I want to override the class, preserving the existing methods, but provided that the "Main arrow" button displays a double arrow instead of a single arrow. Example. See the following URL: www.tiresias.org/images/ff.jpg. All I want to do is change the way I draw this icon.

Thanks,

+4
source share
2 answers

subclass BasicArrowButton and override paintTriangle. You can call the BasicArrowButton paintTriangle method twice to get the triangles. For instance:

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 that looks something like this:

screenshot
(source: amnet.net.au )

+8
source

Simple

Subclass BasicArrowButton and override the paint () method and just draw the image indicated in your question (ff.jpg or any other image) using g. DrawImage () .

Please note that you may need to copy the ff.jpg file to your project and upload it.

Note To do this, you need to create a new class and use it. You cannot modify the existing BasicArrowButton behavior because it does not use an interface delegate.

+1
source

Source: https://habr.com/ru/post/1300729/


All Articles