Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 卸下JComboBox中的向下箭头_Java_Swing_Intellij Idea - Fatal编程技术网

Java 卸下JComboBox中的向下箭头

Java 卸下JComboBox中的向下箭头,java,swing,intellij-idea,Java,Swing,Intellij Idea,我想创建一个自动完成的程序,我正在为此使用JComboBox 现在我想删除JComboBox中的向下箭头。如何删除箭头?是复合的,包含,您可以通过设置图标(null)删除该箭头,或替换为另一个图标 例如(如何通过简单的步骤完成,请注意仅对金属外观有效) JComboBox coloredArrowsCombo=myComboBox; BuffereImage coloredArrowsImage=null; 试一试{ coloredArrowsImage=ImageIO.read(AppVari

我想创建一个自动完成的程序,我正在为此使用
JComboBox

现在我想删除
JComboBox
中的向下箭头。如何删除箭头?

是复合的,包含,您可以通过设置图标(null)删除该箭头,或替换为另一个图标

例如(如何通过简单的步骤完成,请注意仅对
金属外观有效)

JComboBox coloredArrowsCombo=myComboBox;
BuffereImage coloredArrowsImage=null;
试一试{
coloredArrowsImage=ImageIO.read(AppVariables.class.getResource(“resources/passed.png”);
}捕获(IOEX异常){
Logger.getLogger(someClessName.class.getName()).log(Level.SEVERE,null,ex);
}
如果(!(coloredArrowsImage==null)){
Icon coloredArrowsIcon=新图像图标(coloredArrowsImage);
Component[]comp=coloredArrowsCombo.getComponents();
对于(int i=0;i

编辑:为了获得更好的输出,您可以将
coloredArrowsButton.setRolloverIcon(someIcon)放在这里

为什么?不要发明ui小部件,用户会感到困惑!因为我想让你在谷歌上搜索时,你看不到任何箭头,这正是我想在我的JComboBox中显示的。你知道这件事吗?
        JComboBox coloredArrowsCombo = myComboBox;
        BufferedImage coloredArrowsImage = null;
        try {
            coloredArrowsImage = ImageIO.read(AppVariables.class.getResource("resources/passed.png"));
        } catch (IOException ex) {
            Logger.getLogger(someClessName.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (!(coloredArrowsImage == null)) {
            Icon coloredArrowsIcon = new ImageIcon(coloredArrowsImage);
            Component[] comp = coloredArrowsCombo.getComponents();
            for (int i = 0; i < comp.length; i++) {
                if (comp[i] instanceof MetalComboBoxButton) {
                    MetalComboBoxButton coloredArrowsButton = (MetalComboBoxButton) comp[i];
                    coloredArrowsButton.setComboIcon(coloredArrowsIcon);
                    break;
                }
            }
        }