2

I created a GUI and now I created a JLabel, from which I only want to see the top border.

How does it get done?

    JLabel label = new JLabel( "TEXT" );
    label.setBounds( 90, 350, 440, 20 );
    label.setBorder( LineBorder.createBlackLineBorder());
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
SunflowerToadTheOrbiter
  • 1,285
  • 4
  • 15
  • 25
  • http://stackoverflow.com/questions/2174319/is-it-possible-to-have-a-java-swing-border-only-on-the-top-side – Reimeus Mar 30 '16 at 14:24

1 Answers1

4

It's easy

lable.setBorder(new MatteBorder(1, 0, 0, 0, Color.BLACK));
Sergiy Medvynskyy
  • 11,160
  • 1
  • 32
  • 48
  • Read the section from the Swing tutorial on [How to Use Borders](http://docs.oracle.com/javase/tutorial/uiswing/components/border.html) so you become familiar with all the standard Borders. – camickr Mar 30 '16 at 14:26
  • @camickr thanks for the link. I already know about most of the features, but something is new for me :) – Sergiy Medvynskyy Mar 30 '16 at 14:29
  • @SergiyMedvynskyy, my comment was for the OP to read the tutorial and become familiar with Swing features. I like to include links to the tutorial so the OP can learn about all the Borders (as well as other Swing features) the next time they have a problem. This way instead of answering a single question, hopefully I give the OP a resource to use for future problems as well. – camickr Mar 30 '16 at 14:35