• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Swing Borders

 
Nura Horne
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm looking to make a custom border... but only on one side of the rectangle. Basically what I want to do is change the appearance of the line that appears under a JMenuBar... anyone know how?
If I set the border of the JMenuBar to Etched (the style I want) it totally encloses the menu bar, I want it only on the South (bottom) side of the menu bar as for the default appearance. Anyone know how I can do this, either with a Border (preferably) or otherwise.
Also does anyone know how to adjust the width of the bevel on a RaisedBevel border?
Rgds, A
 
Luong Nguyen
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Horne,
This is my code.
import javax.swing.border.LineBorder;
public class BottomLineBorder extends LineBorder {
public BottomLineBorder(Color color) {
super(color);
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
Color oldColor = g.getColor();
g.setColor(lineColor);
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
g.setColor(oldColor);
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!