package org.greenstone.gatherer.gui; import java.awt.*; import java.net.*; import javax.swing.*; public class URLField extends JTextField { public URLField(Color foreground, Color background) { super(); setBackground(background); setForeground(foreground); } public boolean validateURL() { String url_string = getText(); if (!url_string.equals("")) { // Check the URL string is valid by trying to create a URL object from it try { new URL(url_string); } catch (MalformedURLException exception) { // URL string is invalid return false; } } // URL string is valid return true; } }