Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Is there any way to add a border to only ONE side of a button (i.e. north, south, east, west)

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning,

As mentioned above it's quite a simple objective but seems quite complex to accomplish - there seems no in-built method available for adding a border to only one side of a button (which makes sense I suppose since a border is supposed to SURROUND the button).

Any suggestions?

Thank you.

Stephen.
 
Marshal
Posts: 65057
247
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to our GUIs forum.

Did you find anything useful in the Java™ Tutorials? The bottom part of the second image there seems to show a Border on the left only, and the text suggests they set the width to 0 on the other sides, but I didn't read the whole of the link.
 
Saloon Keeper
Posts: 3413
149
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Stephen,

it is certainly possible, what you need is MatteBorder (see the API). I have a KillerSudoku application, where I indicate the groups using this MatteBorder. I made a Map<String, MatteBorder>, where the String is say "TL", meaning the border of the component should be top and left. I can then simply say:

The code I use is: (pixels indicate how large the border part will be, in pixels)


 
Stephen Pillinger
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both - the MatteBorder is definitely the answer here I didn't realise how simple it was until I applied it thanks a lot for the help!
 
Campbell Ritchie
Marshal
Posts: 65057
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephen Pillinger wrote:Thank you . . .

That's a pleasure
 
Piet Souris
Saloon Keeper
Posts: 3413
149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!