How to create TWO border
With the code below, I created 1 border (white). How can I create another border (Black) over the white border?
Image image = icon.getImage().getScaledInstance(widthX,heightY, Image.SCALE_S开发者_JS百科MOOTH);
icon.setImage(image);
int borderWidth = 1;
int spaceAroundIcon = 0;
Color borderColor = Color.WHITE;
BufferedImage bi = new BufferedImage(icon.getIconWidth() + (2 * borderWidth + 2 * spaceAroundIcon),
icon.getIconHeight() + (2 * borderWidth + 2 * spaceAroundIcon), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bi.createGraphics();
g.setColor(borderColor);
g.drawImage(icon.getImage(), borderWidth + spaceAroundIcon, borderWidth + spaceAroundIcon, null);
BasicStroke stroke = new BasicStroke(5); //5 pixels wide g.getStroke();
g.setStroke(stroke);
g.drawRect(0, 0, bi.getWidth() - 1, bi.getHeight() - 1);
g.dispose();
Change the color and the stroke width and use another call to drawRect
!
精彩评论