我正在尝试为Image / ImageView添加边框,但是我不知道该怎么做。
当我按下按钮时,三个随机生成的图像被添加到GridPane中。我尝试通过外部CSS文件添加-fx-border-color
和-fx-border-width
属性,然后应用它,但这种方法无效。
感谢您的帮助!
btnLever.setOnAction((ActionEvent e) ->
{
// New array for loading in the images from 'generateImages' method
String[] fruits = new String[3];
fruits = generateImages();
// GAME WILL RUN IF THE CREDITS IS GREATER THAN 0
if(credits >0)
{
// IMAGES GENERATED
Image img1 = new Image(fruits[0]);
Image img2 = new Image(fruits[1]);
Image img3 = new Image(fruits[2]);
// ADDS IMAGES TO THE GRID
grid.add(new ImageView(img1), 0, 0);
grid.add(new ImageView(img2), 1, 0);
grid.add(new ImageView(img3), 2, 0);