FileDocCategorySizeDatePackage
IsindexView.javaAPI DocJava SE 5 API2555Fri Aug 26 14:58:18 BST 2005javax.swing.text.html

IsindexView

public class IsindexView extends ComponentView implements ActionListener
A view that supports the <ISINDEX< tag. This is implemented as a JPanel that contains
author
Sunita Mani
version
1.11, 12/19/03

Fields Summary
JTextField
textField
Constructors Summary
public IsindexView(Element elem)
Creates an IsindexView

	super(elem);
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent evt)
Responsible for processing the ActionEvent. In this case this is hitting enter/return in the text field. This will construct the URL from the base URL of the document. To the URL is appended a '?' followed by the contents of the JTextField. The search contents are URLEncoded.


	String data = textField.getText();
	if (data != null) {
	    data = URLEncoder.encode(data);
	}


	AttributeSet attr = getElement().getAttributes();
	HTMLDocument hdoc = (HTMLDocument)getElement().getDocument();

	String action = (String) attr.getAttribute(HTML.Attribute.ACTION);
	if (action == null) {
	    action = hdoc.getBase().toString();
	}
	try {
	    URL url = new URL(action+"?"+data);
	    JEditorPane pane = (JEditorPane)getContainer();
	    pane.setPage(url);
	} catch (MalformedURLException e1) {
	} catch (IOException e2) {
	}
    
public java.awt.ComponentcreateComponent()
Creates the components necessary to to implement this view. The component returned is a JPanel, that contains the PROMPT to the left and JTextField to the right.

	AttributeSet attr = getElement().getAttributes();
	
	JPanel panel = new JPanel(new BorderLayout());
	panel.setBackground(null);
	
	String prompt = (String)attr.getAttribute(HTML.Attribute.PROMPT);
	if (prompt == null) {
            prompt = UIManager.getString("IsindexView.prompt");
	}
	JLabel label = new JLabel(prompt);

	textField = new JTextField();
	textField.addActionListener(this);
	panel.add(label, BorderLayout.WEST);
	panel.add(textField, BorderLayout.CENTER);
	panel.setAlignmentY(1.0f);
	panel.setOpaque(false);
	return panel;