0

I'm working on a Look And Feel for java swing, my problem is creating a ComponentUI for components without a UIClassID.

For example, the javax.swing.Box component doesn't have a specific class id, but it does extend JComponent, which returns "ComponentUI" as its class id (JComponent#getUIClassID).

I've tried setting the UI in the UIDefaults, but the createUI method in my custom ComponentUI implementation isn't called.

defaults.put("ComponentUI", FancyComponentUI.class.getName());

Here is the FancyComponentUI class

public class FancyComponentUI extends ComponentUI {

    public static ComponentUI createUI(JComponent c) {
        System.out.println("Something is happening!");
        return new FancyComponentUI();
    }

}

All of the other custom UI's I've made are working absolutely fine, its just the ComponentUI implementation that is the problem.

Caleb
  • 151
  • 2
  • 7
  • Take a look at [this answer](http://stackoverflow.com/questions/26792529/custom-java-swing-component-model-uidelegate-component-format/26793687#26793687), it's a little long winded, but should provide you tips... – MadProgrammer Jan 22 '15 at 23:10
  • I appreciate the response, however this isn't what I'm after, I know how to create custom component UI's, I need to create a UI for components without a specific ComponentUI implementation. Classes such as the javax.swing.Box I cannot modify to add this functionality, so I need to handle it as it is. – Caleb Jan 22 '15 at 23:31
  • Then they are not a UI component, from the look and feel specific and what you "seem" to be trying to do, isn't achievable, at least not the way you are trying to do it... – MadProgrammer Jan 22 '15 at 23:37

0 Answers0