Label

From Documentation
Revision as of 10:42, 19 January 2022 by Hawk (talk | contribs) (correct highlight (via JWB))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


A label component represents a piece of text.

FormAndInput 1.png

<window border="normal"> 
	Hello World
</window>

If you want to add an attribute to a label, it has to be written as follows:

FormAndInput 2.png

<window border="normal">
	<label style="color: red" value="Hello World" />
</window>

Tip: ZUML is XML, not HTML, so it doesn't accept &nbsp;. However, you can use &#160; instead.

The pre, hyphen, maxlength and multiline Properties

[since 5.0.0]

You can control how a label is displayed using the pre, multiline and maxlength properties. For example, if you specify pre to be true, all white spaces, such as new lines, spaces and tabs, are preserved.

pre
multiline
maxlenth
Description
true
any
any
All white spaces are preserved, including new lines, spaces and tabs.
false
true
any
New lines are preserved.
false
false
positive
The label only show its value up to the length of "maxlength".
false
false
0
The label is displayed regularly.

FormAndInput3 ZK5.PNG

<window border="normal" width="300px">
	<vbox id="result">
		<label id="lb1" pre="true" />
		<label id="lb2" multiline="true" />
		<label id="lb3" maxlength="10" />
		<zscript><![CDATA[
			lb1.value = "this   thing   has   spaces.\nnext line.";
			lb2.value = "this   thing   no   space.\nnext line.";
			lb3.value = "this is more than 10 chars.";
		]]></zscript>
	</vbox>
</window>
[For ZK3 users]

This displaying rule is slightly different in ZK3.

hyphen
pre
maxlenth
Description
false
false
positive
Truncated the characters that exceeds the specified maxlength.
true
any
positive
If the length of a line exceeds maxlength, the line is hyphenated.
false
true
any
maxlength is ignored.
any
any
0
hyphen is ignored.

FormAndInput 3.png

 
<window border="normal" width="100px">
	<vbox id="result">
	</vbox>
	<zscript><![CDATA[
		String[] s = {"this is 9", "this is ten more to show",
			"this framework", "performance is everything"};
    	for (int j = 0; j < s.length; ++j) {
			Label l = new Label(s[j]);
			l.maxlength = 9;
			l.hyphen = true;
			l.parent = result;
		}
    ]]>
    </zscript>
</window>

The multiline property is similar to the pre property, except it only preserves new lines and white space at the beginning of each line.



Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.