Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:31:11+00:00 2026-05-27T20:31:11+00:00

I am developing a Look and Feel in Java. When I apply it to

  • 0

I am developing a Look and Feel in Java. When I apply it to my program, I get this exception/error:

UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JButton[,0,0,0x
0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize
=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,pa
intBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,
rolloverSelectedIcon=,selectedIcon=,text=test1111,defaultCapable=true]
java.lang.Error
        at javax.swing.UIDefaults.getUIError(UIDefaults.java:711)
        at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:133)
        at javax.swing.UIDefaults.getUI(UIDefaults.java:741)
        at javax.swing.UIManager.getUI(UIManager.java:989)
        at javax.swing.JButton.updateUI(JButton.java:128)
        at javax.swing.AbstractButton.init(AbstractButton.java:2149)
        at javax.swing.JButton.<init>(JButton.java:118)
        at javax.swing.JButton.<init>(JButton.java:91)
        at com.mypackage.mylaf.MyLookAndFeelTest.main(MyLookAndFeelTest.java:7)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
        at java.lang.Thread.run(Thread.java:619)

My code:

MyButtonUI class

package com.mypackage.mylaf;

public class MyButtonUI extends BasicButtonUI{
    public static ComponentUI createUI(JComponent c) {
        return new MyButtonUI();
    }

    public void paint(Graphics g, JComponent c) {
            super.paint(g, c);
            //paint Button

    }   
}//class

MyLookAndFeel class

package com.mypackage.mylaf;
public class MyLookAndFeel extends BasicLookAndFeel{
    public boolean isSupportedLookAndFeel() {
        return true;
    }

    public boolean isNativeLookAndFeel() {
        return false;
    }

    public String getDescription() {
        return "This is My Look and Feel";
    }

    public String getID() {
        return "MyLookAndFeel";
    }

    public String getName() {
        return "My Look And Feel";
    }


    protected void initClassDefaults(UIDefaults table) {
        super.initClassDefaults(table);

        String myPkg="my.";
        Object[] classes= {"ButtonUI",myPkg+"MyButtonUI"};

        table.putDefaults(classes);
    }//initClassDefaults

    public void initComponentDefaults(UIDefaults table) {
        super.initComponentDefaults(table);

        Object[] defaults= {"Button.font", new Font("Tahoma", Font.PLAIN, 10),
                            "Button.light", new Color(127, 41, 26)
                           };

        table.putDefaults(defaults);
    }//initComponentDefaults
}//MyLookAndFeel

MyLookAndFeelTest class

com.mypackage.mylaf; //1

public class MyLookAndFeelTest{ //2
public static void main(String args[]){//3
try{ UIManager.setLookAndFeel(new MyLookAndFeel()); //4
catch(Exception e){}//5
JFrame f=new JFrame();//6
JButton b=new JButton();//7 , this line is in exception

f.add(b); //8
}

When I set Look and Feel in main code with

UIManager.setLookAndFeel(new MyLookAndFeel());

the above exception is thrown. How can I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:31:11+00:00Added an answer on May 27, 2026 at 8:31 pm

    i resolved my problem,

    in initClassDefaults method in MyLookAndFeel class instead of this line String myPkg="my.";
    i put this code:String myPkg="com.mypackage.mylaf" that is my package.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to learn more about developing a Java look and feel. Could anybody
This problem is solved. I'm am developing a Java Swing based projected, and the
I am developing custom components which fit into the Nimbus look and feel. I'm
I have experience developing web applications using Java, HTML, JS, and CSS. At this
I am developing a web site and need to see how it will look
I have been developing a toy editor, and I want my editor to look
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
Developing a website and just trying to get back into the swing of (clever)
I'm developing a Windows Phone 7 application and I'm trying to change the look
I am developing an app which uses tabs. I want to customize tab look.I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.