【发布时间】:2014-06-05 21:58:26
【问题描述】:
我有一个多层 Java 应用程序,其中包含一系列需要手形光标的 JLabel 按钮,例如:
button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
但是,我在上面有一层覆盖整个应用程序的边界(用于绘制弹出窗口等)。现在我已经添加了上面的图层,我的光标不再改变。我已经尝试将上面图层的光标设置为null,但没有任何影响。
这是图层的基本布局:
private void create() {
this.addWindowListener(windowAdapter);
this.setLayout(new BorderLayout());
layers = new JLayeredPane();
layers.setPreferredSize(this.getSize());
dashboard = new DashBoard.DashBoardLayer();
dashboard.setBounds(0, this.getHeight()-275, this.getWidth(),275);
application = new App.ApplicationLayer();
application.setBounds(0,0,this.getWidth(),this.getHeight()-145);
filter = new FilterLayer();
filter.setBounds(0,195,this.getWidth(),490);
menuBG = MenuLayerBg.getInstance();
menuBG.setBounds(0,0,this.getWidth(),this.getHeight());
menuPanes = MenuLayer.getInstance();
menuPanes.setBounds(0,0,this.getWidth(),this.getHeight());
layers.add(application, new Integer(0));
layers.add(filter, new Integer(1));
layers.add(dashboard, new Integer(2));
layers.add(menuBG, new Integer(3));
layers.add(menuPanes, new Integer(4));
this.add(layers, BorderLayout.CENTER);
}
【问题讨论】:
标签: java swing cursor jlayeredpane