Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Ranch Hand
Posts: 37
  • 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: 69403
276
  • 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.
 
Bartender
Posts: 3956
155
  • 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
Ranch Hand
Posts: 37
  • 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: 69403
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephen Pillinger wrote:Thank you . . .

That's a pleasure
 
Piet Souris
Bartender
Posts: 3956
155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
 
Are you here to take over the surface world? Because this tiny ad will stop you!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic