简体   繁体   中英

Does Java (swing) have a such button?

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

按钮快照

Does Swing have analog or something similar?

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.

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);  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM