import javax.swing.JLabel; /** * Demo that shows how to use the {@link Listmaker} as a Dialog. * * @author Daniele Raffo */ public class ListmakerDialogDemo { public static void main(String[] args) { Object[] result = Listmaker.showListmakerDialog( null, new JLabel("Make a list of tea flavours to serve"), "Listmaker Dialog Demo", new String[] {"Earl Grey", "English Breakfast", "Darjeeling", "Java Green", "Lapsang Souchong", "Marco Polo", "Thé au Sahara", "Thé de Lune", "Thé de Noël", "Buddha Bleu"}, null, true, Listmaker.SORT_LIST1); System.out.printf(getSelection(result)); } public static String getSelection(Object[] selection) { StringBuffer buf; if (selection == null) buf = new StringBuffer("You canceled your selection."); else { if (selection.length == 0) buf = new StringBuffer("You have selected nothing."); else { buf = new StringBuffer("You have selected:\n " + selection[0]); int i = 1; while (i < selection.length) buf.append(", " + selection[i++]); buf.append("."); } } return buf.toString(); } }