Here is a partial example, the image used is a gif with black as transparent
=================== create a UIManager ================================
if (windowMgr == null) {
try {
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
} catch (Exception a) {
a.printStackTrace();
}
windowMgr = new UIWindowManager(canvas); <===use your canvas Canvas3D
}
========================create, position a book page ============================
bookWindow = new BookPage(null, 256, 256, true, true); <====alpha blend/clip alpha true
windowMgr.addOverlay(bookWindow);
windowMgr.setPosition(bookWindow, x, y);
windowMgr.setVisible(toolsWindow, true); <===remember to set visible
=========================partial source ====================================
public class BookPage extends UIWindow implements ActionListener {
FPSPanel1 panel;
public BookPage(JComponent root, int width, int height, boolean clipAlpha,
boolean blendAlpha) {
super(width, height, clipAlpha, blendAlpha);
w = width;
h = height;
img = TextureLoader.tf.getImageAlpha("images/parchment2.gif"); <===load as alpha
panel = buildGUI(width, height);
panel.setOpaque(false); <====remember not opaque
this.setRoot(panel);
}
private FPSPanel1 buildGUI(int width, int height) {
FPSPanel1 p = new FPSPanel1();
p.setLayout(null);// new BorderLayout());
p.setDoubleBuffered(true);
p.setOpaque(false);
p.setSize(new Dimension(width, height));
p.setLocation(0, 0);
p.setBackground(Color.darkGray);
return p;
}
class FPSPanel1 extends JPanel {
public void paint(Graphics g) {
g.setFont(font);
g.drawImage(img, 0, 0, w, h, null); <===draw background
g.setColor(Color.BLACK);
Iterator it = lines.iterator();
while (it.hasNext()) { <===drawing text on bg alpha image
String p = (String) it.next();
g.drawString(p, 25, offset);
offset += 20;
}
//paint components
this.paintComponents(g);
super.paintChildren(g);
}
}
</sub>