Example usage for javax.swing JList setVisible

List of usage examples for javax.swing JList setVisible

Introduction

In this page you can find the example usage for javax.swing JList setVisible.

Prototype

@BeanProperty(hidden = true, visualUpdate = true)
public void setVisible(boolean aFlag) 

Source Link

Document

Makes the component visible or invisible.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    DefaultListModel<String> dlm = new DefaultListModel();
    String[] modelElems = { "Apple", "Orange", "Banana" };
    for (int i = 0; i < modelElems.length; i++)
        dlm.add(i, modelElems[i]);/* w w  w.j  av a 2 s .c o  m*/

    JList<String> lstFruitList = new JList(dlm);
    lstFruitList.setVisible(true);

    JPanel p = new JPanel();
    p.add(lstFruitList);
    f.add(p);
    f.setLocation(0, 0);
    f.setSize(400, 400);
    f.setVisible(true);
}

From source file:ru.goodfil.catalog.ui.forms.FilterWindow.java

private static void showValidationPanel(JList list, ValidationResult result) {
    list.setBorder(new LineBorder(Color.BLACK));
    list.setBackground(Color.YELLOW);

    list.setCellRenderer(new MessagesRenderer());

    if (result.isEmpty()) {
        list.setVisibleRowCount(0);//from w  w  w  .  j a  v a  2s .c  om
        list.setVisible(false);
    } else {
        list.setVisibleRowCount(result.getErrors().size());
        list.setModel(new ArrayListModel<ValidationMessage>(result.getErrors()));
    }

    list.repaint();
}