开发者

UIManager.put("Panel.opaque", false); does not work

开发者 https://www.devze.com 2023-04-06 04:27 出处:网络
Setting UIManager.put(\"Panel.opaque\", false); does not work. I need to call panel.setOpaque(false); for each panel.

Setting UIManager.put("Panel.opaque", false); does not work. I need to call panel.setOpaque(false); for each panel.

what can b开发者_开发问答e the problem?


You can create a custom JPanel class and use it instead of JPanel.

class MyJPanel extends JPanel{

  public MyJPanel(){
     setOpaque(false);
  }
}


Why not use a JComponent instead? It is non-opaque by default.


I don't see that constant when i do

    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    Set<Entry<Object, Object>> entries = defaults.entrySet();
    for (Entry<Object, Object> entry : entries) {
        System.out.print(entry.getKey() + " = ");
        System.out.print(entry.getValue() + "\n");


Since the method deals with default values, you have to put it at the very beginning of your program to make it work, or probably before calling other GUI related methods. The only thing that should come before it is locale.

0

精彩评论

暂无评论...
验证码 换一张
取 消