Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package States;
- import java.awt.Color;
- import java.awt.Component;
- import javax.swing.JPanel;
- import org.pushingpixels.trident.Timeline;
- import org.pushingpixels.trident.Timeline.RepeatBehavior;
- public class FadePanel {
- public JPanel panel = new JPanel();
- public JPanel panel2 = new JPanel();
- public Component fade() {
- panel.setBounds(0,0,800,600);
- panel.setBackground(new Color(0,0,0,0));
- final Timeline timeline = new Timeline(panel);
- timeline.addPropertyToInterpolate("background", panel.getBackground(),
- Color.white);
- timeline.setDuration(600); //0.6 second total fade in
- timeline.playLoop(2, RepeatBehavior.REVERSE); //fades in, then out, making 1.2 total seconds
- return panel;
- }
- public Component fadeFlash() {
- panel2.setBounds(0,0,800,600);
- panel2.setBackground(new Color(0,0,0,5));
- final Timeline timeline = new Timeline(panel2);
- timeline.addPropertyToInterpolate("background", panel2.getBackground(),
- Color.white);
- timeline.setDuration(600); //0.6 second total fade in
- timeline.playLoop(1, RepeatBehavior.REVERSE); //fades in, then out, making 1.2 total seconds
- return panel2;
- }
- }
Add Comment
Please, Sign In to add comment