This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
When i add this ComboBox to a Frame, it has a look and feel diffrent from the others componet How to resolve that
Regards
Jackm
Brian Cole
Author
Ranch Hand
Joined: Sep 20, 2005
Posts: 852
posted
0
jack morton wrote:I created this custom ComboBox:
When i add this ComboBox to a Frame, it has a look and feel diffrent from the others componet How to resolve that
If you know what L&F will be used, you can override the specific ComboBoxUI for that L&F (though it may have a structure that differs from BasicComboBoxUI, which can make it difficult). Of course it's typical to expect your code to be run under a variety of L&Fs.
This is a general problem with Swing. For this reason you don't really want to override UIs to change functionality, though sometimes there's no other way. I just spent a few minutes looking for some example code I saw somewhere that uses crazy reflection techniques to (effectively) override a method in a dynamic UI delegate, but I couldn't find it. The technique probably wouldn't have worked for your situation anyway.
luck, db
There are no new questions, but there may be new answers.
Carlos Hoces
Greenhorn
Joined: Mar 02, 2009
Posts: 2
posted
0
jack morton wrote:Hi all,
I created this custom ComboBox:
[code]import com.sun.java.swing.*;
import com.sun.java.swing.plaf.basic.*;
public class myCombo extends JComboBox{
public myCombo(){
super();
setUI(new myComboUI());
}
Jackm
In case you extend your class, like:
public class HComboBox extends myCombo{
public HComboBox(){
this.updateUI();
...
}
will set the current LaF during the execution of your class constructor.
This is how I use it, and it works well with Substance LaF, ie.
I guess if you do the same with your class, as is, it'll work equally well.