Cannot change background color of button

Bob B's Avatar

Bob B

10 Jul, 2021 10:57 PM

I'm trying to change the background color of a button in my extension. Nothing I do will cause it to change from the colors of the buttons in the rest of the MD app. I found the following discussion:

which suggested subclassing the button. I tried that exactly as written but I still don't get any change in my button color. I can change the font but not the color.

Any help would be appreciated.

This is my button class:

public class MyButton extends JButton {
    public MyButton() {
    public void updateUI() {
  1. 1 Posted by Bob B on 10 Jul, 2021 11:04 PM

    Bob B's Avatar

    Here is a screenshot of the window. The button labeled 'Show Returns' uses the new MyButton class, the others do not.

  2. 2 Posted by Stuart Beesley ... on 11 Jul, 2021 05:07 AM

    Stuart Beesley - JUST A FELLOW USER and Toolbox ‘guy’'s Avatar

    Odd. I do this all this time. No subclassing, extension, or overrides... Example Jython script below (you can paste/run in Moneybot):

    from java.awt import Color
    from javax.swing import JFrame, JButton, JLabel, JPanel

    I know you're in pure java, but should be no different.....

  3. 3 Posted by Bob B on 12 Jul, 2021 04:13 PM

    Bob B's Avatar

    Thanks. I think the difference might be that I am running as an extension. I'm not the only one with the issue (see link in original post) but the solution there didn't work for me and I'm not sure why.

  4. 4 Posted by Bob B on 22 Jul, 2021 12:17 AM

    Bob B's Avatar

    Does anyone have an answer for me? I know it's not the end of the world but it's bugging me (mostly because I'm kinda new at this and can't figure it out).

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac