Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java (swing) have a such button?

Tags:

java

swing

At example libre office has button with drop down menu, but it isn't combobox:

Button Snapshot

Does Swing have analog or something similar?

like image 489
mystdeim Avatar asked Mar 06 '13 13:03

mystdeim


2 Answers

There's no SplitButton implementation provided by Java. I provided a link to another question on this site in my comment on potential implementations and would add that Jidesoft has also an implementation of a SplitButton in their open source JIDE Common Layer, check the licenses first.

like image 164
Jonathan Drapeau Avatar answered Oct 03 '22 23:10

Jonathan Drapeau


Not directly, but you can easily achieve it by wrapping an ImageIcon into a Button. (arrow_down.png is the downwards pointing, black arrow)

button = new JButton();  
button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/icons/arrow_down.png")));  
button.setBorderPainted(false);  
button.setFocusPainted(false);  
button.setContentAreaFilled(false);  
like image 26
poitroae Avatar answered Oct 04 '22 00:10

poitroae