【问题标题】:Java how to create Not clickable JlistJava如何创建不可点击的Jlist
【发布时间】:2013-10-24 08:49:11
【问题描述】:

此图片取自 netbean,选项 1. 和 2. 不可点击。 我在 Jlist 中有类似的设置,但是当我 setenabled(false) 项目变为灰色时,我希望它保持黑色,如上所示。

【问题讨论】:

    标签: java swing colors jlist


    【解决方案1】:

    此图片取自 netbean,选项 1. 和 2. 不是 可点击。我在 Jlist 中有类似的设置,但是当我 setenabled(false) 项目变为灰色,我希望它保持黑色, 如上图所示。

    对于禁用的JList,您可以更改UIManager.put("Label.disabledForeground", Color.magenta); 中的密钥

    编辑

    你可以一起玩

    UIManager.put("List.background", Color.lightGray);
    UIManager.put("List.selectionBackground", Color.orange);
    UIManager.put("List.selectionForeground", Color.blue);
    UIManager.put("Label.disabledForeground", Color.magenta);
    

    或类似的方法也可以在XxxListCellRenderer 中覆盖,无需为UIManager 设置任何值

    【讨论】:

      猜你喜欢
      • 2014-06-05
      • 2012-11-07
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多