aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JComboBox with horizontall scroll bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox with horizontall scroll bar" Watch "JComboBox with horizontall scroll bar" New topic
Author

JComboBox with horizontall scroll bar

jack morton
Greenhorn

Joined: Dec 10, 2008
Posts: 16
Hi all,
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
Regards
Jackm
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 863
    
    1
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.

[edit: spell delegate correctly]


bitguru blog
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

Just another cross poster.
http://forums.sun.com/thread.jspa?threadID=5369365


luck, db
There are no new questions, but there may be new answers.
Carlos Hoces
Greenhorn

Joined: Mar 02, 2009
Posts: 2
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JComboBox with horizontall scroll bar