Skip to content

Commit 76aa2be

Browse files
author
atarw
committed
slight changes to animation to make it easier (doesn't break any
existing code)
1 parent ef16f56 commit 76aa2be

File tree

4 files changed

+47
-59
lines changed

4 files changed

+47
-59
lines changed

.idea/workspace.xml

Lines changed: 36 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public class MaterialUIDemo2 {
3434
content.add (button);
3535
frame.add (content, BorderLayout.CENTER);
3636

37-
// on hover, button will change to a light blue at about 30 FPS with 5 intermediate color changes
38-
MaterialUIMovement.add (button, new Color (34, 167, 240), 5, 1000 / 30);
37+
// on hover, button will change to a light blue
38+
MaterialUIMovement.add (button, new Color (34, 167, 240));
3939

4040
frame.pack ();
4141
frame.setVisible (true);

src/MaterialUISwingDemo.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ public static void main (String[] args) {
5555

5656
// start animating!
5757
// here, 'gray' is the color that the JComponent will transition to when the user hovers over it
58+
Color gray = new Color (230, 230, 230);
59+
MaterialUIMovement.add (menu1, gray);
60+
MaterialUIMovement.add (item1, gray);
61+
62+
// you can also pass in extra parameters indicating how many intermediate colors to display, as well as the "frame rate" of the animation
5863
// there will be 5 intermediate colors displayed in the transition from the original component color to the new one specified
5964
// the "frame rate" of the transition will be 1000 / 30, or 30 FPS
6065
// the animation will take 5 * 1000 / 30 = 166.666... milliseconds to complete
61-
Color gray = new Color (230, 230, 230);
62-
MaterialUIMovement.add (menu1, gray, 5, 1000 / 30);
63-
MaterialUIMovement.add (item1, gray, 5, 1000 / 30);
64-
65-
// you can probably figure out what this does based on the explanation above
66-
// the only difference is a new color
6766
Color blue = new Color (34, 167, 240);
6867
MaterialUIMovement.add (button, blue, 5, 1000 / 30);
6968

src/mdlaf/MaterialUIMovement.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ public static void add (JComponent c, Color fadeTo, int steps, int interval) {
3434
new MaterialUITimer (getColors (c.getBackground (), fadeTo, steps), c, interval);
3535
}
3636

37+
public static void add (JComponent c, Color fadeTo) {
38+
add (c, fadeTo, 5, 1000 / 30);
39+
}
40+
3741
private MaterialUIMovement () {}
3842
}

0 commit comments

Comments
 (0)