-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathButtonStyle.java
35 lines (28 loc) · 1.08 KB
/
ButtonStyle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package potplayer;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.control.Button;
public class ButtonStyle {
// private can only be used class internally
public void changeButtonColor(Button button) {
ColorAdjust colorAdjust = new ColorAdjust();
button.setOnMousePressed(event -> {
colorAdjust.setBrightness(0.3);
button.setEffect(colorAdjust);
});
button.setOnMouseReleased(event -> {
colorAdjust.setBrightness(0);
button.setEffect(colorAdjust);
});
}
public void changeButtonImage(Button button, String imageName, int width, int height) {
imageName = getClass().getResource(imageName).toString();
Image icon = new Image(imageName);
ImageView imageView = new ImageView(icon);
imageView.setFitWidth(width);
imageView.setFitHeight(height);
// imageView.setFitHeight((int)(30 * icon.getHeight() / icon.getWidth()));
button.setGraphic(imageView);
}
}