Setting JPanel colors has no effect in the toolwindow

已回答
        this.contentFactory = ContentFactory.getInstance();
        this.contentManager = toolWindow.getContentManager();

        JPanel jPanel = new JPanel(new BorderLayout());
        JLabel jLabel = new JLabel("hi, is my chat");
        jLabel.setOpaque(true);
        jLabel.setBackground(Color.RED);
        jPanel.setBackground(Color.RED);
        jPanel.add(jLabel, BorderLayout.CENTER);

        Content content = contentFactory.createContent(jPanel, "", false);
        contentManager.addContent(content);

How to solve the problem of color in the desired effect? Thank you

0

Hi,

It is not possible to do by plugins.

Background of all components is overriden in https://github.com/JetBrains/intellij-community/blob/243/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.kt . See InternalDecoratorImpl.Companion#setBackgroundRecursively() calls. This is an internal API, and I don't see any way of disabling this behavior by plugins.

1

Make sure you're calling setBackground(@) on the correct component and that it's opaque (setOpaque(true)). ToolWindows may override styling.

0

Hi,

It is not possible to do by plugins.

Background of all components is overriden in https://github.com/JetBrains/intellij-community/blob/243/platform/platform-impl/src/com/intellij/openapi/drift boss/wm/impl/ToolWindowImpl.kt . See InternalDecoratorImpl.Companion#setBackgroundRecursively() calls. This is an internal API, and I don't see any way of disabling this behavior by plugins.

You’re correct setBackgroundRecursively() in ToolWindowImpl enforces the background styling at the platform level, and since it’s internal API there’s no supported extension point or override. At the plugin layer this behavior can’t be disabled or intercepted; the only options would be patching the platform itself or filing a feature request upstream.

0

请先登录再写评论。