系统设置的背景工作不在我的控制

0

的问题

我曾尝试做一个老鼠的事件在我的系统项目,该项目是当老鼠进入的背景的颜色会变化和当鼠退出会给空,但这个错误只是保持未来:

The method setBackground(Background) in the type Region is not applicable for the arguments (Color)

该方法在我的控制器类:

public void barcolor(MouseEvent event) {
    menubar.addEventHandler(MouseEvent.MOUSE_ENTERED, e ->
        menubar.setBackground(Color.WHITE)          
    );      
    menubar.addEventHandler(MouseEvent.MOUSE_EXITED, e ->
        menubar.setBackground(null)         
    );      
}
background javafx setbackground
2021-11-22 19:38:41
1

最好的答案

0
Background mouseOverBackground = new Background(new BackgroundFill(Paint.valueOf("WHITE"),  5, 15));


public void barcolor(MouseEvent event) {
    menubar.addEventHandler(MouseEvent.MOUSE_ENTERED, e ->
        menubar.setBackground(new Background(new BackgroundFill(Paint.valueOf("WHITE"),  5, 15)))          
    );      
    menubar.addEventHandler(MouseEvent.MOUSE_EXITED, e ->
        menubar.setBackground(null)         
    );      
}

你需要确保通过正确的参数。 该setBackground()命令只接受BackgroundFill()和图像()作为参数。 保存的背景变量,或插入它直接进入功能。

2021-11-23 23:57:01

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................