public SwingURLEditor() {
// setup filechooser
chooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
chooser.setMultiSelectionEnabled( false );
// textfield
textfield = new JTextField();
textfield.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
setValue( new URL(textfield.getText()) );
} catch (MalformedURLException e1) {
}
}
});
//button
UIDefaults table = UIManager.getDefaults();
table.put("beaninfo.OpenIcon", LookAndFeel.makeIcon(getClass(), "icons/open16.gif"));
Icon openIcon = UIManager.getIcon("beaninfo.OpenIcon");
urlChooserButton = new JButton(openIcon);
urlChooserButton.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
int returnVal = chooser.showOpenDialog( panel.getParent() );
if(returnVal == JFileChooser.APPROVE_OPTION) {
setTheValue();
}
}
});
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(textfield);
panel.add( urlChooserButton );
}