Ivan Viktorovic
Ivan Viktorovic

Reputation: 143

Java GUI up and down buttons

im creating a JAVA Swing Gui atm and i got an issue.

I want to create a list with items and the user should be able to sort the list using some kind of "elementUP" and "elementDown" buttons. Right now im useing buttons with simple chars like ^ and v but they look different.

So my question is are there some Swing or AWT build in function to create such "up" and "down" buttons? If not what are the typical solutions for this kind of problem? Creating an image and setting that image to the button like proposed in Using pictures as buttons? ?

my gui http://s22.postimage.org/ytk62h1d9/up_Down_Java.png

Thanks for your time

Upvotes: 1

Views: 2445

Answers (3)

Catalina Island
Catalina Island

Reputation: 7126

BasicArrowButton is another way, like they show here and here.

Upvotes: 3

BlackBox
BlackBox

Reputation: 2233

There are two easy ways of doing this:

Unicode

An easy implementation is to use simple unicode character to represent the meaning using, .setText(unicodecharacter), read more here: Arrows_in_Unicode

Image

As you suggested, if you just want an arrow looking component, mimic it using an image.

Upvotes: 1

Kai
Kai

Reputation: 39641

You could

  • use text ("up", "down")
  • try unicode characters (▲, ▼)
  • try to figure out how icons are shown in the scrollbar
  • use images (like you mentioned)

Choose your favorite.

Upvotes: 3

Related Questions