How do i change the UI of a JComboBox

梦想与她 提交于 2020-01-02 20:23:16

问题


I like to change the UI of a JComboBox from the default metal look to some custom UI, see attached image.

I have tried changing all the UIDefaults for the JComboBox but to no success.

How does one achieve this?

jdk1.4.2


回答1:


You have to write your own ComboBoxUI class. I suggest to look at either Synth or Nimbus Look and Feel to make it easier.




回答2:


you need to change arrow image , and in style change background for this JComboBox !




回答3:


use WindowsLookAndFeel;

this works if and only if you are running your application in winows;

in your main you can do this before creating any UI:


try{
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception ignore){
}


来源:https://stackoverflow.com/questions/1026559/how-do-i-change-the-ui-of-a-jcombobox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!