public static class Embed.ETextComponent extends Embed implements java.awt.event.FocusListener
<img id="textareaA" aligny="0.84" embed="JTextArea"
src="images/textarea.png" width="100"
title="Click to type" note="Click here to type"/>
where width is in characters.
In some cases the title is a popup hint; usually it seems to be ignored.
The note value is the initial, grayed-out contents of the text. When the
component gets the focus, the note is cleared.
Small bits of text can be directly embedded into HTML.
SpeedsConverge has a document, bounceText.html
,
that displays a current speed with this html
<span id="bspeedspan">‌</span>‌‌70.
The Java code modifies the speed value like this
Element bspeedspan = doc.getElement("bspeedspan"); int end = bspeedspan.getEndOffset(); String ins = String.format("%3d", (int)(x-BALL_R)); ins = ins.substring(0, 3); // stymie long drags ins = ins.replace(' ', ''); // ‌ zero-width try { doc.replace(end+1, 3, ins, null); } catch (BadLocationException ex) { Message.impossible("setting B speed"); }
Embed.EAbstractButton, Embed.EButton, Embed.ECheckBox, Embed.EComboBox, Embed.EFilename, Embed.ELabel, Embed.EList, Embed.EPanel, Embed.ERadioButton, Embed.ESpinner, Embed.ETextComponent
Modifier and Type | Method and Description |
---|---|
static Embed.ETextComponent |
create(java.lang.String initial,
javax.swing.text.AttributeSet attrs) |
void |
focusGained(java.awt.event.FocusEvent e) |
void |
focusLost(java.awt.event.FocusEvent e) |
javax.swing.text.JTextComponent |
getComponent()
Returns the unique JComponent instance managed by
the subclass of Embed.
|
disable, enable, forwardAction, getAttributes, getElt, getView, isHidden
public static Embed.ETextComponent create(java.lang.String initial, javax.swing.text.AttributeSet attrs)
public javax.swing.text.JTextComponent getComponent()
Embed
getComponent
in class Embed
public void focusGained(java.awt.event.FocusEvent e)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent e)
focusLost
in interface java.awt.event.FocusListener