JLayer 和 glass pane 的用法刚刚相反。 JFrame.setGlassPane()用于截取用户鼠标事件,以及之后的重新dispatch events,还有就是painting over all the components laid in JFrame。 而JLayer用于接收用户对于components的鼠标事件,以及处理process这些事件等当然也可以设置event mask来选择处理。但是和glass pane的事件传递路径是相反的。绘制的graphics是可以单独和某个Component绑定。
JFrame.setGlassPane()用于截取用户鼠标事件,以及之后的重新dispatch events,还有就是painting over all the components laid in JFrame。
而JLayer用于接收用户对于components的鼠标事件,以及处理process这些事件等当然也可以设置event mask来选择处理。但是和glass pane的事件传递路径是相反的。绘制的graphics是可以单独和某个Component绑定。