Guest User

Untitled

a guest
Jan 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. package States;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import javax.swing.JPanel;
  6.  
  7. import org.pushingpixels.trident.Timeline;
  8. import org.pushingpixels.trident.Timeline.RepeatBehavior;
  9.  
  10. public class FadePanel {
  11. public JPanel panel = new JPanel();
  12. public JPanel panel2 = new JPanel();
  13. public Component fade() {
  14. panel.setBounds(0,0,800,600);
  15. panel.setBackground(new Color(0,0,0,0));
  16.  
  17. final Timeline timeline = new Timeline(panel);
  18. timeline.addPropertyToInterpolate("background", panel.getBackground(),
  19. Color.white);
  20. timeline.setDuration(600); //0.6 second total fade in
  21.  
  22. timeline.playLoop(2, RepeatBehavior.REVERSE); //fades in, then out, making 1.2 total seconds
  23. return panel;
  24. }
  25. public Component fadeFlash() {
  26. panel2.setBounds(0,0,800,600);
  27. panel2.setBackground(new Color(0,0,0,5));
  28.  
  29. final Timeline timeline = new Timeline(panel2);
  30. timeline.addPropertyToInterpolate("background", panel2.getBackground(),
  31. Color.white);
  32. timeline.setDuration(600); //0.6 second total fade in
  33.  
  34. timeline.playLoop(1, RepeatBehavior.REVERSE); //fades in, then out, making 1.2 total seconds
  35. return panel2;
  36. }
  37. }
Add Comment
Please, Sign In to add comment