/*
* @(#)ListTest.java 1.0 13 February 2005
*
* Copyright (c) 2004 Werner Randelshofer, Immensee, Switzerland.
* All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the
* license agreement you entered into with Werner Randelshofer.
* For details see accompanying license terms.
*/
package test;
import javax.swing.JComponent;
import javax.swing.JList;
/**
* ListTest.
*
* @author Werner Randelshofer
* @version 1.0 13 February 2005 Created.
*/
public class ListTest extends javax.swing.JPanel {
/** Creates new form. */
public ListTest() {
initComponents();
stripedList.putClientProperty("Quaqua.List.style","striped");
disabledList.setEnabled(false);
disabledList.setSelectedIndex(1);
verticalRadio.putClientProperty("layoutOrientation", JList.VERTICAL);
hwrapRadio.putClientProperty("layoutOrientation", JList.HORIZONTAL_WRAP);
vwrapRadio.putClientProperty("layoutOrientation", JList.VERTICAL_WRAP);
list.setVisibleRowCount(0);
stripedList.setVisibleRowCount(0);
disabledList.setVisibleRowCount(0);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
layoutOrientationGroup = new javax.swing.ButtonGroup();
jScrollPane2 = new javax.swing.JScrollPane();
list = new javax.swing.JList();
jLabel5 = new javax.swing.JLabel();
jSeparator10 = new javax.swing.JSeparator();
jScrollPane8 = new javax.swing.JScrollPane();
stripedList = new javax.swing.JList();
jLabel6 = new javax.swing.JLabel();
jSeparator11 = new javax.swing.JSeparator();
jScrollPane9 = new javax.swing.JScrollPane();
disabledList = new javax.swing.JList();
disabled = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jPanel1 = new javax.swing.JPanel();
verticalRadio = new javax.swing.JRadioButton();
hwrapRadio = new javax.swing.JRadioButton();
vwrapRadio = new javax.swing.JRadioButton();
setBorder(javax.swing.BorderFactory.createEmptyBorder(16, 17, 17, 17));
setLayout(new java.awt.GridBagLayout());
list.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Apple", "Banana", "Cantaloupe", "Cherry", "Grape", "Lemon", "Mango", "Melon", "Orange", "Peach", "Pear", "Pineapple", "Plum", "Strawberry" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane2.setViewportView(list);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(jScrollPane2, gridBagConstraints);
jLabel5.setText("Plain Style");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12);
add(jLabel5, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 0);
add(jSeparator10, gridBagConstraints);
stripedList.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Agnolotti", "Bavette", "Cannelloni", "Cappellini", "Conchiglie", "Ditalini", "Eliche", "Farfalle", "Fettuccine", "Fusilli", "Garganelli", "Gnocchi", "Lasagne", "Linguine", "Macaroni", "Orecchiette", "Orzo", "Panzarotti", "Pappardelle", "Penne", "Pizzoccheri", "Ravioli", "Rigatoni", "Spaghetti", "Tagliattelle", "Tortellini", "Trenette", "Vermicelli", "Ziti" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane8.setViewportView(stripedList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(jScrollPane8, gridBagConstraints);
jLabel6.setText("Striped Style");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12);
add(jLabel6, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 0);
add(jSeparator11, gridBagConstraints);
disabledList.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Bari", "Biga", "Buccellato", "Bruschetta", "Ciabatta", "Calzone", "Casatiello", "Ciriola", "Farinata", "Focaccia", "Grissini", "Muffuletta", "Pane", "Pandoro", "Panettone", "Panino", "Penia", "Piadina", "Pita", "Pizza", "Rosetta", "Taralli", "Tortano" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane9.setViewportView(disabledList);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(jScrollPane9, gridBagConstraints);
disabled.setText("Disabled");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12);
add(disabled, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 0);
add(jSeparator1, gridBagConstraints);
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
layoutOrientationGroup.add(verticalRadio);
verticalRadio.setSelected(true);
verticalRadio.setText("Vertical");
verticalRadio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
layoutOrientationRadioPerformed(evt);
}
});
jPanel1.add(verticalRadio);
layoutOrientationGroup.add(hwrapRadio);
hwrapRadio.setText("Horizontal Wrap");
hwrapRadio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
layoutOrientationRadioPerformed(evt);
}
});
jPanel1.add(hwrapRadio);
layoutOrientationGroup.add(vwrapRadio);
vwrapRadio.setText("Vertical Wrap");
vwrapRadio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
layoutOrientationRadioPerformed(evt);
}
});
jPanel1.add(vwrapRadio);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
add(jPanel1, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
private void layoutOrientationRadioPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_layoutOrientationRadioPerformed
int lo= (Integer)((JComponent)evt.getSource()).getClientProperty("layoutOrientation");
stripedList.setLayoutOrientation(lo);
disabledList.setLayoutOrientation(lo);
list.setLayoutOrientation(lo);
}//GEN-LAST:event_layoutOrientationRadioPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel disabled;
private javax.swing.JList disabledList;
private javax.swing.JRadioButton hwrapRadio;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane8;
private javax.swing.JScrollPane jScrollPane9;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator10;
private javax.swing.JSeparator jSeparator11;
private javax.swing.ButtonGroup layoutOrientationGroup;
private javax.swing.JList list;
private javax.swing.JList stripedList;
private javax.swing.JRadioButton verticalRadio;
private javax.swing.JRadioButton vwrapRadio;
// End of variables declaration//GEN-END:variables
}