-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
subhra74
committed
Oct 3, 2019
1 parent
de8cf5d
commit 451804a
Showing
10 changed files
with
289 additions
and
77 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/main/java/snowflake/components/common/RoundedButtonPainter.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,62 @@ | ||
package snowflake.components.common; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class RoundedButtonPainter { | ||
private Painter<JButton> normalPainter, hotPainter, pressedPainter; | ||
private GradientPaint normalGradient, hotGradient, pressedGradient; | ||
private Color borderColor; | ||
|
||
public RoundedButtonPainter() { | ||
this.normalGradient = new GradientPaint(0, 0, | ||
new Color(245, 245, 245), | ||
0, 50, | ||
new Color(235, 235, 235)); | ||
this.hotGradient = new GradientPaint(0, 0, | ||
new Color(255, 255, 255), | ||
0, 50, | ||
new Color(230, 230, 230)); | ||
this.pressedGradient = new GradientPaint(0, 0, | ||
new Color(230, 230, 230), | ||
0, 50, | ||
new Color(180, 180, 180)); | ||
this.borderColor = new Color(230, 230, 230); | ||
|
||
normalPainter = (Graphics2D g, JButton object, int width, int height) -> { | ||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); | ||
g.setPaint(normalGradient); | ||
g.fillRoundRect(1, 1, width - 2, height - 2, 7, 7); | ||
g.setColor(borderColor); | ||
g.drawRoundRect(1, 1, width - 2, height - 2, 7, 7); | ||
}; | ||
|
||
hotPainter = (Graphics2D g, JButton object, int width, int height) -> { | ||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); | ||
g.setPaint(hotGradient); | ||
g.fillRoundRect(1, 1, width - 2, height - 2, 7, 7); | ||
g.setColor(borderColor); | ||
g.drawRoundRect(1, 1, width - 2, height - 2, 7, 7); | ||
}; | ||
|
||
pressedPainter = (Graphics2D g, JButton object, int width, int height) -> { | ||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); | ||
g.setPaint(pressedGradient); | ||
g.fillRoundRect(1, 1, width - 2, height - 2, 7, 7); | ||
g.setColor(borderColor); | ||
g.drawRoundRect(1, 1, width - 2, height - 2, 7, 7); | ||
}; | ||
} | ||
|
||
public Painter<JButton> getNormalPainter() { | ||
return normalPainter; | ||
} | ||
|
||
public Painter<JButton> getHotPainter() { | ||
return hotPainter; | ||
} | ||
|
||
public Painter<JButton> getPressedPainter() { | ||
return pressedPainter; | ||
} | ||
} |
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
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
Oops, something went wrong.