Java – hide jcombox box arrow

Can I hide it JCombo@R_773_2419 @Arrows shown in

I tried setting:

combo.getComponent(0).setSize(new Dimension(1,1));

But it doesn't seem to work

Solution

You must create a new combo box UI for this:

combo.setUI(new BasicCombo@R_773_2419@UI() {
    protected JButton createArrowButton() {
        return new JButton() {
            public int getWidth() {
                return 0;
            }
        };
    }
});

But be careful to inherit from the basic UI to match your current appearance

For example, if you use substance, you should SubstanceCombo@R_773_2419 @UI instead of BasicCombo@R_773_2419 @UI derivation new UI Otherwise, you may lose the functions currently provided by L & F

Editor: if you want to get some kind of autocomplete function, you'd better stick to the ordinary jtextfield and use the autocompletedecorator of swingx

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>