List of usage examples for javax.swing JComboBox isVisible
@Transient public boolean isVisible()
From source file:Main.java
public static void main(String[] args) { JFrame result = new JFrame(); JComboBox<String> combobox = new JComboBox<>(new String[] { "foo", "bar", "aaa", "Hello World" }); result.add(combobox, BorderLayout.CENTER); JCheckBox toggleVisibility = new JCheckBox("Toggle visibility"); toggleVisibility.setSelected(combobox.isVisible()); toggleVisibility.addItemListener(e -> { combobox.setVisible(e.getStateChange() == ItemEvent.SELECTED); });/*from w ww. j ava 2 s.c om*/ result.add(toggleVisibility, BorderLayout.SOUTH); result.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result.pack(); result.setVisible(true); }