Java gif splashscreen奇怪的bug
发布时间:2020-12-15 02:10:15 所属栏目:Java 来源:网络整理
导读:今天,我已经测试过使用 java splashscreen选项显示gif. 它正在工作,但是……在闪屏的重复中,我的gif显示了一个奇怪的图形错误…… 此错误仅出现在Java应用程序中. 这是原来的gif: 代码 public class Bootstrap {private SplashScreen splash;public static
今天,我已经测试过使用
java splashscreen选项显示gif.
它正在工作,但是……在闪屏的重复中,我的gif显示了一个奇怪的图形错误…… 此错误仅出现在Java应用程序中. 这是原来的gif: 代码 public class Bootstrap { private SplashScreen splash; public static void main(String[] args) { Bootstrap bootstrap = new Bootstrap(); bootstrap.start(); } public void start() { // Here i load the splash splash = new SplashScreen("UC",new ImageIcon(getClass().getResource("splash3.gif")).getImage()); AWTUtilities.setWindowOpaque(splash,false); splash.setVisible(true); } } SplashScreen.java public class SplashScreen extends JFrame { public SplashScreen(String title,Image image) { this.setTitle(title); this.setUndecorated(true); this.setDefaultCloSEOperation(3); this.setSize(image.getWidth(this),image.getHeight(this)); this.setLocationRelativeTo((Component)null); this.setContentPane(new SplashPanel(image)); } } Splashpanel.java class SplashPanel extends JPanel { private Image image; public SplashPanel(Image image) { this.image = image; } public void paintComponent(Graphics g) { g.drawImage(this.image,this.getWidth(),this.getHeight(),this); } } 显然这只是因为gif是隔行扫描的. :)从photoshop导出你的gif时取消选中这个… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |