KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > swing > DirectoryURLEditor


1 /*
2
3   Copyright (C) 2001 Renaud Pawlak, Laurent Martelli
4   
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU Lesser General Public License as
7   published by the Free Software Foundation; either version 2 of the
8   License, or (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   GNU Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

18
19 package org.objectweb.jac.aspects.gui.swing;
20
21 import org.objectweb.jac.core.rtti.FieldItem;
22 import java.awt.event.ActionEvent JavaDoc;
23 import javax.swing.JFileChooser JavaDoc;
24
25 /**
26  * This is a special value editor that allows the user to nicely edit
27  * an URL. */

28
29 public class DirectoryURLEditor extends URLEditor {
30    
31    public DirectoryURLEditor(Object JavaDoc substance, FieldItem field) {
32       super(substance,field);
33    }
34
35    public void actionPerformed(ActionEvent JavaDoc evt) {
36       if (evt.getActionCommand().equals("choose")) {
37          JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
38          chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
39          int returnVal = chooser.showOpenDialog( this );
40          if ( returnVal == JFileChooser.APPROVE_OPTION ) {
41             textField.setText( "file:" + chooser.getSelectedFile().toString() );
42          }
43       }
44    }
45 }
46
Popular Tags