如何在一个jframe向另一个jframe进行过渡动画更新(淡入、淡出)?

huangapple 未分类评论53阅读模式
英文:

How can you update transition animation(fade in, fade out) from jframe to another jframe?

问题

我尝试过,但似乎过渡效果不够平滑,点击某些按钮后,按钮没有打开或执行淡入/淡出的动画过渡。以下是我的代码:

for (double i = 1.0; i >= 0.0; i = i - 0.1) {
    String val = i + "";
    float f = Float.valueOf(val);
    this.setOpacity(f);
    try {
        Thread.sleep(30);
    } catch (Exception e) {
        
    }
    StockItems a = new StockItems();
    a.setVisible(true);
    a.setLocationRelativeTo(null);
    dispose();
}
英文:

I tried doing it but it seems like the transition is not fading in smoothly and some of the buttons after I clicked it is not opening or doing the animation transition of fade in/out. Here's my code:

        for (double i = 1.0; i >=0.0; i=i-0.1){
           String val=i+"";
        float f = Float.valueOf(val);
         this.setOpacity(f);
        try{
            Thread.sleep(30);
       }catch(Exception e){
           
       }
           StockItems a = new StockItems();
            a.setVisible(true);
            a.setLocationRelativeTo(null);
            dispose();
       
    }

huangapple
  • 本文由 发表于 2020年3月15日 14:44:57
  • 转载请务必保留本文链接:https://java.coder-hub.com/60690403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定