[英]How do I “combine” JButton with JComboBox?
How do I "combine" JButton with JComboBox and place it on a JToolbar, as shown in this image: 如何将JButton与JComboBox结合在一起,并将其放在JToolbar上,如下图所示:
?
?
您将要使用我怀疑的自定义渲染器 ,并使其显示可单击的按钮(附带适当的操作,等等)。
Just create regular combo box and put image as an item. 只需创建常规组合框并将图像作为项目即可。 I did it once.
我做了一次。 Unfortunately I do not have a source code here but as far as I remember it was not a problem.
不幸的是,我这里没有源代码,但据我所知这不是问题。 You have to implement your custom 1ListCellRenderer
. Its method
您必须实现自定义1ListCellRenderer
. Its method
. Its method
getListCellRendererComponent()` should return for example Label with your image. . Its method
getListCellRendererComponent()应该返回例如带有图像的Label。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.