Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Can we disable JComboBox arrow button in Java?
Yes, we can do that using removeArrow() method.
The following is an example to disable JComboBox arrow button:
Example
import java.awt.Component;
import java.awt.Container;
import javax.swing.*;
public class SwingDemo {
public static void main(String[] args) {
String[] strValues = {"One", "Two"};
JComboBox<String> comboBox = new JComboBox<String>(strValues);
removeArrow(comboBox);
JOptionPane.showMessageDialog(null, comboBox);
}
private static void removeArrow(Container container) {
Component[] c = container.getComponents();
for (Component res : c) {
if (res instanceof AbstractButton) {
container.remove(res);
}
}
}
}
Output

Advertisements
