Example usage for javax.swing JList JList

List of usage examples for javax.swing JList JList

Introduction

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

Prototype

public JList() 

Source Link

Document

Constructs a JList with an empty, read-only, model.

Usage

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList();
    jlist1.setListData(labels);//from  w ww .ja  v  a 2  s.  c  o m

    jlist1.setVisibleRowCount(4);
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    ListCellRenderer r = jlist1.getCellRenderer();

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList();
    jlist1.setListData(labels);//from  w  ww.  j a v a2  s.c  o  m

    jlist1.setVisibleRowCount(4);
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    ListSelectionModel model = jlist1.getSelectionModel();

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList();
    jlist1.setListData(labels);//from  ww  w  .java2 s. c om

    jlist1.setVisibleRowCount(4);
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    int s = jlist1.getFixedCellWidth();

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList();
    jlist1.setListData(labels);/*from w w  w  .j av a 2s.  co  m*/

    jlist1.setVisibleRowCount(4);
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    ListSelectionListener[] lis = jlist1.getListSelectionListeners();

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList();
    jlist1.setListData(labels);/*from w  w  w .  j  a v a 2s . c  o  m*/

    jlist1.setVisibleRowCount(4);
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    boolean b = jlist1.getDragEnabled();

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList();
    jlist1.setListData(labels);//from ww w.  j ava  2s  .co m

    jlist1.setVisibleRowCount(4);
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    int s = jlist1.getFixedCellHeight();

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:Main.java

public static JList getListBarChart() {
    JList list = new JList();
    list.setVisibleRowCount(-1);/*from www  . j  a v a  2  s . co  m*/
    list.setBackground(Color.WHITE);
    return list;
}

From source file:Main.java

public static Color getBackgroundColor() {
    if (backgroundColor != null) {
        return backgroundColor;
    }/*from w  w w.j  a  va2  s .  com*/

    backgroundColor = UIManager.getColor("Table.background");
    if (backgroundColor == null) {
        backgroundColor = new JList().getBackground();
    }
    //sometimes the UIManager color won't work
    backgroundColor = new Color(backgroundColor.getRed(), backgroundColor.getGreen(),
            backgroundColor.getBlue());

    return backgroundColor;
}

From source file:Main.java

public static Color getForegroundColor() {
    if (foregroundColor != null) {
        return foregroundColor;
    }/*from   w w  w . j a  v  a2 s  . co  m*/

    foregroundColor = UIManager.getColor("Table.foreground");
    if (foregroundColor == null) {
        foregroundColor = new JList().getForeground();
    }

    //sometimes the UIManager color won't work
    foregroundColor = new Color(foregroundColor.getRed(), foregroundColor.getGreen(),
            foregroundColor.getBlue());

    //sometimes the UIManager color won't work
    return foregroundColor;
}

From source file:Main.java

/**
 * Get the foreground color for the current UI.
 * @return The desired foreground color.
 *//*from  www  . j a  v a  2  s . c  o  m*/
public static Color getSelectionForegroundColor() {
    if (selectionForegroundColor != null) {
        return selectionForegroundColor;
    }

    //for windows
    selectionForegroundColor = (Color) Toolkit.getDefaultToolkit()
            .getDesktopProperty("win.item.highlightTextColor");
    if (selectionForegroundColor == null) {
        selectionForegroundColor = UIManager.getColor("Table.selectionForeground");
        if (selectionForegroundColor == null) {
            selectionForegroundColor = UIManager.getColor("Table[Enabled+Selected].textForeground");
            if (selectionForegroundColor == null) {
                selectionForegroundColor = new JList().getSelectionForeground();
            }
        }

        //sometimes the UIManager color won't work
        selectionForegroundColor = new Color(selectionForegroundColor.getRed(),
                selectionForegroundColor.getGreen(), selectionForegroundColor.getBlue());
    }

    return selectionForegroundColor;
}