/************************************************************************** /* This class is the main driver class for the guiwidgets demo. /* /* Copyright (c) 2006 by Bernhard Bablok (mail@bablokb.de) /* /* This program is free software; you can redistribute it and/or modify /* it under the terms of the GNU General Public License as published /* by the Free Software Foundation; either version 2 of the License or /* (at your option) any later version. /* /* This program is distributed in the hope that it will be useful, but /* WITHOUT ANY WARRANTY; without even the implied warranty of /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /* GNU General Public License for more details. /* /* You should have received a copy of the GNU General Public License /* along with this program; see the file COPYING. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.greef.ui.calendar.*; import com.l2fprod.common.swing.*; import org.netbeans.api.wizard.*; import org.netbeans.spi.wizard.*; /** This class is the main driver class for the guiwidgets demo. @version $Revision: 1.4 $ @author $Author: bablokb $ */ public class Main extends JFrame { ////////////////////////////////////////////////////////////////////////////// /** Constructor. */ public Main() { super("GUI-Widget Demo"); getContentPane().setLayout(new BorderLayout()); getContentPane().add("Center",getButtonBar()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setLocation(100, 100); setVisible(true); } ////////////////////////////////////////////////////////////////////////////// /** Create ButtonBar */ private JPanel getButtonBar() { ButtonBarPanel bbp = new ButtonBarPanel(); bbp.addPanel(getCalendarPanel(),"calendar","calendar.png"); bbp.addPanel(getDirChooserPanel(),"directory","directory.png"); bbp.addPanel(getFontChooserPanel(),"fonts","fonts.png"); bbp.addPanel(getWizardPanel(),"wizard","wizard.png"); return bbp; } ////////////////////////////////////////////////////////////////////////////// /** Create a calendar with a jcalendar-widget. */ private JPanel getCalendarPanel() { JCalendar cal = new JCalendar(); return new WidgetPanel("A Calendar-Widget",cal); } ////////////////////////////////////////////////////////////////////////////// /** Create a panel with a button which triggers the directory-chooser. */ private JPanel getDirChooserPanel() { JButton button = new JButton("Select Directory...", new ImageIcon("directory.png")); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSelectDir(); }}); return new WidgetPanel("Choose Directory",button); } ////////////////////////////////////////////////////////////////////////////// /** Show the JDirectoryChooser. */ private void doSelectDir() { JDirectoryChooser dirChooser = new JDirectoryChooser(); dirChooser.setMultiSelectionEnabled(true); int choice = dirChooser.showOpenDialog(this); if (choice == JDirectoryChooser.APPROVE_OPTION) { StringBuffer filenames = new StringBuffer(); File[] selectedFiles = dirChooser.getSelectedFiles(); for (int i = 0; i