• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom Swing Borders

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic