我可以将光标从系统更改为一个,但无法显示我创建的光标,而且我完全不知道我做错了什么,它不会给我任何异常。这是我的代码:
class CustomWin extends MainFrame{
title = "SdC2 Launcher"
cursor = defineCursor
iconImage = defineIcon
visible = true
contents = new BoxPanel(Orientation.Vertical){
contents += new Label("Label de prueba")
contents += new Label("Label de prueba")
val lab = new Label("Label de prueba")
lab cursor = defineCursor
contents += lab
}
preferredSize = new Dimension(300,300)
centerOnScreen
pack
open
private val defineCursor = {
val hotspot = new Point(0, 0)
//val image = ImageIO.read(new File("images/cursor.png"))
val image = new ImageIcon("/images/cursor2.gif")
toolkit.createCustomCursor(image.getImage(), hotspot, "MainCursor")
}
private val defineIcon: Image = new ImageIcon(getClass().getResource("/images/cursor.png")).getImage()
}