1 /*
2
3 dsh-curate-examples Examples for the curate library.
4 Copyright (c) 2007-2012 held jointly by the individual authors.
5
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 3 of the License, or (at
9 your option) any later version.
10
11 This library is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19
20 > http://www.fsf.org/licensing/licenses/lgpl.html
21 > http://www.opensource.org/licenses/lgpl-license.php
22
23 */
24 package org.dishevelled.curate.examples;
25
26 import java.awt.BorderLayout;
27
28 import java.util.ArrayList;
29 import java.util.List;
30
31 import javax.swing.JFrame;
32 import javax.swing.JPanel;
33 import javax.swing.SwingUtilities;
34
35 import org.dishevelled.curate.impl.CullDialog;
36 import org.dishevelled.curate.impl.CullPanel;
37
38 /**
39 * Cull view example.
40 *
41 * @author Michael Heuer
42 * @version $Revision$ $Date$
43 */
44 public final class CullViewExample
45 extends JPanel
46 implements Runnable
47 {
48 /** List of strings. */
49 private final List<String> strings;
50
51 /** Cull dialog. */
52 private final CullDialog<String> cullDialog;
53
54 /** Cull panel. */
55 private final CullPanel<String> cullPanel;
56
57
58 /**
59 * Cull view example.
60 */
61 public CullViewExample()
62 {
63 strings = new ArrayList<String>();
64 for (int i = 0; i < 100; i++)
65 {
66 strings.add("string" + i);
67 }
68
69 cullDialog = new CullDialog<String>();
70 cullDialog.setTitle("Cull view example dialog");
71 cullPanel = new CullPanel<String>();
72
73 cullDialog.setInput(strings);
74 cullPanel.setInput(strings);
75
76 setLayout(new BorderLayout());
77 add("Center", cullPanel);
78 }
79
80
81 /** {@inheritDoc} */
82 public void run()
83 {
84 JFrame f = new JFrame("Cull view example");
85 f.setContentPane(this);
86 f.setBounds(100, 100, 400, 400);
87 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
88 f.setVisible(true);
89
90 cullDialog.setBounds(200, 200, 400, 400);
91 cullDialog.setVisible(true);
92 }
93
94
95 /**
96 * Main.
97 *
98 * @param args command line arguments, ignored
99 */
100 public static void main(final String[] args)
101 {
102 SwingUtilities.invokeLater(new CullViewExample());
103 }
104 }