Hi
I’m trying to get transparent components into the overlay with xith. The following code is how i’m creating my object I’m trying to set it so that the text is non transparent, the first colour block is non transparent, the middle block is semi transparent, and the last block is 100% transparent. All that currently happens is that the colour is scaled by the alpha chanel, so the 100% transparent part comes out black, the 50% comes out dark blue.
I add the panel by calling
UIWindow window = new UIWindow(component, width, height, true, true);
uiComponentMap.put(component, window);
uiWindowManager.addOverlay(window);
uiWindowManager.setPosition(window, x, y);
uiWindowManager.setVisible(window, true);
Does anyone know what i’m doing wrong?, or have any required debug info?
Cheers
Endolf
public class TestLabel extends JPanel {
private Color backGroundColour = new Color(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue(), 255);
private Color backGroundColourFaded = new Color(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue(), 128);
private Color backGroundColourAlphad = new Color(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue(), 0);
private Color clearColour = new Color(Color.white.getRed(), Color.white.getGreen(), Color.white.getBlue(), 0);
/** Creates a new instance of TestLabel */
public TestLabel() {
setDoubleBuffered(true);
setSize(250, 100);
setLocation(0,0);
}
public void paint(Graphics graphics) {
if(graphics == null) {
System.out.println("Erm, panel.getGraphics() is null");
} else {
System.out.println("Graphics is of type: " + graphics.getClass().getName());
}
graphics.setPaintMode();
graphics.setColor(clearColour);
graphics.fillRect(0,0,249,99);
graphics.setColor(backGroundColour);
graphics.fillRect(0,0,90,99);
graphics.setColor(backGroundColourFaded);
graphics.fillRect(90,0,90,99);
graphics.setColor(backGroundColourAlphad);
//graphics.fillRect(180,0,69,99);
graphics.setColor(java.awt.Color.WHITE);
graphics.drawRect(0,0,249,99);
graphics.setColor(java.awt.Color.WHITE);
graphics.drawString("Test", 2 ,2 + graphics.getFontMetrics().getAscent() );
}
}
