📄 textboxprimitive.java
字号:
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.FormPrimitives;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;/** * The TextBoxPrimitive class encapsulates the details of * building the HTML for a text entry box. */public class TextBoxPrimitive implements IHtmlPrimitive{ private String name; private String type = "text"; private String initialValue; private int maximumLength = -1; private int width = -1; private boolean readOnly = false; private Style style; /** Construct a TextBoxPrimitive with the specified name * for the form element.*/ public TextBoxPrimitive(String name) { this.name = name; } /** Set the initial value that is displayed when this * TextBoxPrimitive is rendered. */ public void setInitialValue(String initialValue) { this.initialValue = initialValue; } /** Set the maximum number of characters to accept. */ public void setMaximumLength(int maximumLength) { this.maximumLength = maximumLength; } /** Set the width of the text box in characters */ public void setWidth(int width) { this.width = width; } /** Set the text box to read only. */ public void setReadOnly() { this.readOnly = true; } /** Hide the text box so that it is not rendered by the browser. */ public void setHidden() { this.type = "hidden"; } /** Mask the input to the browser to protect it from prying eyes. */ public void setMasked() { this.type = "password"; } /** Specify the style class that is applied to the text box. */ public void setStyle(Style style) { this.style = style; } /** Build the content for this primitive and append it to the * specified buffer.*/ public void buildContent(StringBuffer buffer) { String type_string = Formatting.convertToAttribute("type", type); String name_string = Formatting.convertToAttribute("name", name); String value_string = Formatting.convertToAttribute("value", initialValue); String maxlength_string = Formatting.convertToAttribute("maxlength", maximumLength); String size_string = Formatting.convertToAttribute("size", width); String read_only_string = Formatting.convertToAttribute("readonly", readOnly); String style_string = Formatting.convertToAttribute("class", style); buffer.append("<input" +type_string+name_string+value_string+ maxlength_string+size_string+read_only_string+style_string+ ">"); buffer.append("</input>"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -