-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from vincenzopalazzo/fixsomeissue
Fix some issue
- Loading branch information
Showing
7 changed files
with
145 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/mdlaf/animation/MaterialUIStaticMovement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package mdlaf.animation; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.MouseEvent; | ||
import java.awt.event.MouseListener; | ||
|
||
/** | ||
* This class recreate a effect mouse hover static, | ||
* This component not implement a wake effect, and is util in all component for click, an example: The button for JSpinner, JCombobox, JScroolbar | ||
* @author https://github.com/vincenzopalazzo | ||
*/ | ||
class MaterialUIStaticMovement implements MouseListener { | ||
|
||
private Color before; | ||
private Color after; | ||
private Color strongOnClick; | ||
|
||
public MaterialUIStaticMovement(Color before, Color after, Color strongOnClick) { | ||
this.before = before; | ||
this.after = after; | ||
this.strongOnClick = strongOnClick; | ||
} | ||
|
||
@Override | ||
public void mouseClicked(MouseEvent e) { | ||
/*For effect click, need create a timer ?*/ | ||
/* if(e == null){ | ||
throw new IllegalArgumentException("MouseEvent null"); | ||
} | ||
setColorComponent(e, after);*/ | ||
} | ||
|
||
@Override | ||
public void mousePressed(MouseEvent e) { | ||
/*For effect click, need create a timer ?*/ | ||
if(e == null){ | ||
throw new IllegalArgumentException("MouseEvent null"); | ||
} | ||
setColorComponent(e, strongOnClick); | ||
} | ||
|
||
@Override | ||
public void mouseReleased(MouseEvent e) { | ||
/*For effect click, need create a timer ?*/ | ||
if(e == null){ | ||
throw new IllegalArgumentException("MouseEvent null"); | ||
} | ||
setColorComponent(e, after); | ||
} | ||
|
||
@Override | ||
public void mouseEntered(MouseEvent e) { | ||
if(e == null){ | ||
throw new IllegalArgumentException("MouseEvent null"); | ||
} | ||
setColorComponent(e, after); | ||
} | ||
|
||
@Override | ||
public void mouseExited(MouseEvent e) { | ||
if(e == null){ | ||
throw new IllegalArgumentException("MouseEvent null"); | ||
} | ||
setColorComponent(e, before); | ||
} | ||
|
||
/*** | ||
* This is service method for recicle code | ||
*/ | ||
private void setColorComponent(MouseEvent e, Color colorComponent){ | ||
if(e == null || colorComponent == null){ | ||
throw new IllegalArgumentException("The argument function is/are null"); | ||
} | ||
JComponent component = (JComponent) e.getSource(); | ||
if(component.isEnabled()){ | ||
component.setBackground(colorComponent); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters