我要做的是点击按钮创建并将新图像加载到面板。图像应该是可拖动的,以及我能够在屏幕上找到它的位置等。我不知道如何做到这一点。这个想法是经过多次点击我将有多个新图像都可以拖动和移动。
代码如下所示: -
val top = new MainFrame {
//General code for menus
val button = new Button {
text = "Click for Image"
}
val panel = new Panel {
override def paint(g:Graphics2D){
}
listenTo (button
mouse.clicks,
mouse.moves)
reactions += {
case ButtonClicked(`button`) => {
new ImagePanel{ imagePath = ("bottoming.jpg")}
}
case e: MousePressed =>{}
case e: MouseDragged =>{}
case e: MouseReleased =>{}
}
}
import BorderPanel.Position._
contents =
new BorderPanel {
layout += new Label("label") -> North
layout += panel -> Center
layout += button -> West
}
}