get Arrow L&F of JCombo and Place it on a JButton

I want to get the L&F of the JCombo's Arrow Button and place it on my JButton. How do I do that?
LVL 18
armoghanAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
It may not necessarily be using an image. Some L&F's may handling the arrow painting in the code so there isn't a L&F indepent way to get the arrow image.
0
 
CEHJCommented:
Why not just add an arrow icon?

<long URL removed -- Lunchy>
0
 
CEHJCommented:
Ugh sorry about that url. I'll try to get it removed. Here's the same one:

http://tinyurl.com/8nz9m
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
armoghanAuthor Commented:
ohh no no..
Actually I am using  a control which is mimicing JCombo.

It also has an Arrow button similar to JCombo's arrow button.

Now I am using this control and my JCombo on places. I want both of them to have a similar look and feel.

Now users are using different themes. Most are using XP theme..
They see two different types of combos in a Panel.

So the solution which i thought was to get the look& Feel of JCombo's arrow "Somehow" and place it on the  Mimiced JCombo's arrow Button.



0
 
CEHJCommented:
Sorry - i've never had enough commitment to Java guis to get in as deep as LAF ;-) Someone else may be along ...
0
 
armoghanAuthor Commented:
Ahh
lets hope Objects, zzynx or anyone else comes for the resuce

I have tried
com.sun.java.swing.plaf.windows.WindowsIconFactory.*
but it has all teh icons but the combo and
and dont know how to get it from
com.sun.java.swing.plaf.windows.WindowsComboBoxUI.*
0
 
armoghanAuthor Commented:
got it with an ugly way
Extended WindowsComboBoxUI and made createArrowButton method Public

 MyWindowsComboBoxUI myWindowsComboBoxUI = new MyWindowsComboBoxUI();
 JButton b = myWindowsComboBoxUI.createArrowButton();
 b.setPreferredSize(new Dimension(16,16));


But I am open for a better way
0
 
armoghanAuthor Commented:
I have tried BasicArrowButton.. But I could not give it the L&F of Combo in different XP themes

 javax.swing.plaf.basic.BasicArrowButton bb = new javax.swing.plaf.basic.
            BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton.SOUTH);
Now I can set the color, How about RollOver image and other things.
0
 
objectsCommented:
XP L&F uses a different class, it uses XPComboBoxButton which is a private static inner class of the Windows ComboBox L&F.

0
 
armoghanAuthor Commented:
Yes I have seen that and that is the way I have done. Also mentioned above

Extended com.sun.java.swing.plaf.windows.WindowsComboBoxUI and made createArrowButton method Public

 MyWindowsComboBoxUI myWindowsComboBoxUI = new MyWindowsComboBoxUI();
 JButton b = myWindowsComboBoxUI.createArrowButton();
 b.setPreferredSize(new Dimension(16,16));

But this restricts me to Windows Look and Feel. If user changes to anyother look&feel then the combo arrow may be different
0
 
objectsCommented:
As the combo L&F doesn't provide public access to the arrow it'll be difficult to come up with a L&F indepentant solution.
Perhaps pulling it out of the JComboBox itself might be the way to go.
0
 
armoghanAuthor Commented:
ohh u mean some thing like

        JComboBox aCombo = new JComboBox();
        JButton anyLFButton= (JButton)aCombo.getComponent(0);
0
 
objectsCommented:
yes, a bit kludgy but can't think how else you'll get L&F independance.
0
 
armoghanAuthor Commented:
I have tried it but unfortunately it has not worked for me.

the problem was that the other component has a Rectangle and all the drawing is done on it.
So i am unable to replace the rectangle by the button.

Is there a way I can get all the Images of this anyLFButton? I have checked its RollOverIcon and other methods but they return Null.

So do i need to resort to Robot class to get the image?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.