1
我有一個需要6秒鐘才能啓動的應用程序,我想添加一個啓動畫面。 我有這樣的代碼:Java SplashScreen透明圖像
public class SplashScreen extends JWindow {
private static final long serialVersionUID = 1L;
Image bi;
ImageIcon ii;
boolean loaded = false;
public SplashScreen(String path) {
try {
bi = Toolkit.getDefaultToolkit().getImage(path);
ii = new ImageIcon(bi);
setSize(ii.getIconWidth(), ii.getIconHeight());
setLocationRelativeTo(null);
loaded = true;
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void showSplashScreen(boolean flag) {
if (!loaded) {
System.err.println("Splash screen image isn't loaded.");
return;
}
setVisible(flag);
}
public void dispose() {
dispose();
}
public void paint(Graphics g) {
g.drawImage(bi, 0, 0, null);
}
}
圖片看起來不錯,但我希望它看起來透明,我不能得到它。
[見下面的鏈接,讓您的圖像透明] [1] [ 1]:http://stackoverflow.com/questions/665406/how-to-make-a-color-transparent-in-a-bufferedimage-and-save-as-png – Muhammad
@穆罕默德我的形象是Png透明.. 這就是爲了創建具有透明度的圖像PNG – Dementor