private MutableTreeNode createImagePainterDemos() {
DefaultMutableTreeNode node = createInfoNode("Image Painter Demos", null);
try {
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("border.gif"));
node.add(createInfoNode("small image", new ImagePainter(img)));
} catch (Exception ex) {
ex.printStackTrace();
}
try {
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("moon.jpg"));
node.add(createInfoNode("big image", new ImagePainter(img)));
} catch (Exception ex) {
ex.printStackTrace();
}
try {
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("border.gif"));
ImagePainter ip = new ImagePainter(img);
ip.setHorizontalRepeat(true);
node.add(createInfoNode("horizontal repeat", ip));
} catch (Exception ex) {
ex.printStackTrace();
}
try {
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("border.gif"));
ImagePainter ip = new ImagePainter(img);
ip.setVerticalRepeat(true);
node.add(createInfoNode("vertical repeat", ip));
} catch (Exception ex) {
ex.printStackTrace();
}
try {
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("border.gif"));
ImagePainter ip = new ImagePainter(img);
ip.setBorderPaint(Color.BLACK);
node.add(createInfoNode("image with black border", ip));
} catch (Exception ex) {
ex.printStackTrace();
}
try {
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("a-glyph.png"));
node.add(createInfoNode("An image of 'A' with transparent parts",
new ImagePainter(img)));
} catch (Exception ex) {
ex.printStackTrace();
}
try {
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("a-glyph.png"));
ImagePainter ip = new ImagePainter(img);
ip.setFillPaint(Color.RED);
node.add(createInfoNode("red background visible through transparent parts", ip));
} catch (Exception ex) {
ex.printStackTrace();
}