diff options
Diffstat (limited to 'libjava/classpath/javax/swing/text/html/FormView.java')
-rw-r--r-- | libjava/classpath/javax/swing/text/html/FormView.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libjava/classpath/javax/swing/text/html/FormView.java b/libjava/classpath/javax/swing/text/html/FormView.java index b85c6943404..d54021066d0 100644 --- a/libjava/classpath/javax/swing/text/html/FormView.java +++ b/libjava/classpath/javax/swing/text/html/FormView.java @@ -39,8 +39,11 @@ exception statement from your version. */ package javax.swing.text.html; import java.awt.Component; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -83,6 +86,24 @@ public class FormView implements ActionListener { + protected class MouseEventListener + extends MouseAdapter + { + /** + * Creates a new <code>MouseEventListener</code>. + */ + protected MouseEventListener() + { + // Nothing to do here. + } + + public void mouseReleased(MouseEvent ev) + { + String data = getImageData(ev.getPoint()); + imageSubmit(data); + } + } + /** * If the value attribute of an <code><input type="submit">> * tag is not specified, then this string is used. @@ -227,4 +248,28 @@ public class FormView { // FIXME: Implement this. } + + /** + * Determines the image data that should be submitted in response to a + * mouse click on a image. This is either 'x=<p.x>&y=<p.y>' if the name + * attribute of the element is null or '' or + * <name>.x=<p.x>&<name>.y=<p.y>' when the name attribute is not empty. + * + * @param p the coordinates of the mouseclick + */ + String getImageData(Point p) + { + String name = (String) getElement().getAttributes() + .getAttribute(HTML.Attribute.NAME); + String data; + if (name == null || name.equals("")) + { + data = "x=" + p.x + "&y=" + p.y; + } + else + { + data = name + ".x=" + p.x + "&" + name + ".y=" + p.y; + } + return data; + } } |