Re: cobbling a ComboBox



On 2008-06-24 14:42 +0100, Albretch Mueller allegedly wrote:
(new javax.swing.JComboBox()).getUI() I causing a NP Exception
~ sh-3.1# javac DanieleFurttorovic00.java
sh-3.1# java DanieleFurttorovic00
UIDefaults.getUI() failed: no ComponentUI class for:
javax.swing.JComboBox[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,
flags=16777224,maximumSize=,minimumSize=,preferredSize=,isEditable=false,
lightWeightPopupEnabled=true, maximumRowCount=8,selectedItemReminder=One]

Mind the package directory structure.

Note the package declaration in the code I posted:
package scratch;

This is important for the following line to work:
UIManager.put("ComboBoxUI", "scratch.Test$CustomMetalComboBoxUI");
(the runtime will try a Class.forName(String) with the value of that entry).

You need a directory X. Then you need the code in
X/scratch/Test.java

go to directory X, compile. Run *from that directory* using
"java -cp . scratch.Test"

This should work.

Since you weren't able to resolve that error on your own, I assume there
will be at least some things in that code you might not understand.
Please, try to figure them out (GIYF). Don't simply copy and paste code.
It would be nigh-worthless that way. I won't give you an overall
explanation, but if you come back at me with specific points, I'll try
my best to lay them out.

Always read the JavaDocs:
<http://java.sun.com/javase/6/docs/api/>

Check the SUN tutorials:
<http://java.sun.com/docs/books/tutorial/reallybigindex.html>

--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
.



Relevant Pages

  • Re: cobbling a ComboBox
    ... I causing a NP Exception ... sh-3.1# javac DanieleFurttorovic00.java ... sh-3.1# java DanieleFurttorovic00 ... UIDefaults.getUIfailed: no ComponentUI class for: ...
    (comp.lang.java.gui)
  • Re: cobbling a ComboBox
    ... sh-3.1# java DanieleFurttorovic00 ... UIDefaults.getUIfailed: no ComponentUI class for: ... Mind the package directory structure. ...
    (comp.lang.java.gui)