We help IT Professionals succeed at work.

EtchedBorder

vibhav
vibhav asked
on
HI!

I want to apply etchedborder to the only top side of the panel(not all side). how to achieve it ?

Thanks,
Comment
Watch Question

Commented:
Instead of a border, why not just add a JSeparator instead?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Write your own border class.
hi

This applies the etched border to top and bottom

you can customize it according to your needs

public class CustomBorder extends EtchedBorder
{

  public CustomBorder()
  {
      super();
  }

  public void paintBorder(Component c , Graphics g , int x , int y , int width , int height)
  {
        int w = width;
     int h = height;


     g.translate(x, y);
     g.setColor(etchType == LOWERED? getShadowColor(c) : getHighlightColor(c));
    g.drawRect(0, 0, w-3, 0);
     g.setColor(etchType == LOWERED? getHighlightColor(c) : getShadowColor(c));
     g.drawLine(1, 1, w-3, 1);
     g.translate(-x, -y);


  }
}


hope this helps

Explore More ContentExplore courses, solutions, and other research materials related to this topic.