锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
I feel there is a need for this because the documentation that comes with the SDK is rather unhelpful. The SDK says, basically, that widget styles are conventionally named [project]-[widget], e.g., gwt-Button, and style names correspond to CSS class names, so in order to style your button you would include something like
.gwt-Button { font-size: 150%; }
in your stylesheet. And that鈥檚 all it says. Really.
I believe this documentation to be inadequate for a number of reasons.
DialogBox class, for one, does not follow the rule.
*-selected*) are used in different or even contradictory manners making it hard to generalize your experience from one widget to another.
ListBox class should, according to both the general rule above and the specific class documentation, implement a style named gwt-ListBox. Nope, not there. Grep the source directory if you don鈥檛 believe me.
If I鈥檝e left out a class below, it鈥檚 probably because it doesn鈥檛 participate in styling in any way. (I hope.) If you鈥檙e trying to read this straight through instead of just jumping to an item of interest, more power to you. If you find yourself yawning you might want to skip around a bit.
With that said鈥?/p>
Implemented as a DIV and by default sets
overflow to
hidden. Contents are positioned absolutely according to given
x,
y values unless
x == -1 and
y == -1 in which case the widget is positioned statically.
<div style="overflow: hidden;"></div>
Implemented as HTML BUTTON. Default style name is
gwt-Button and is used. No default attributes. Can contain text or HTML.
<button class="gwt-Button" />
Implemented as a TABLE. No default styles. Can set
border and
cell-spacing attributes.
<table> </table>
Implemented as HTML CHECKBOX. Default style name is
gwt-CheckBox and is used. Automatically generates unique id of the form
checkN where
N is an integer. Uses
checked,
defaultChecked, and
disabled attributes. No default styles.
<checkbox class="gwt-CheckBox" />
Implemented using a DIV containing any number of children. The visibility of the individual children are controlled using the
display attribute. The
DeckPanel sets
display to
'none' or
'' as appropriate.
<div style="width: 100%; height: 100%"></div>
Default style names are gwt-DialogBox and
Caption and are both used. Implemented as a
DIV and the caption is also a
DIV. (Technically, the caption is an
HTML, which is a
Label, which is implemented using a
DIV.)
<div class="gwt-DialogBox"> <table cell-spacing="0" cell-padding="0"> <tbody> <tr>
聽聽聽聽聽聽<td><div class="Caption">caption</div></td> </tr> <tr> <td> content </td> </tr> </tbody> </table> </div>
Implemented using TABLE.
cell-spacing and
cell-padding attributes both default to 0. Nesting of
TR and
TD elements can get quite complicated in order to achieve desired layout.
<table cell-spacing="0" cell-padding="0"> <tbody> </tbody> </table>
Just a TABLE, there鈥檚 nothing funky going on here.
<table> <tbody> </tbody> </table>
Implemented as a DIV with
display set to
inline.
<div style="display: inline;">content</div>
A DIV.
FocusPanel is only important in that it publishes a number of events (
FOCUSEVENTS,
KEYEVENTS,
ONCLICK, and
MOUSEEVENTS) and is very useful for containing widgets that don鈥檛 publish their own events. See Drag-and-Drop with the Google Web Toolkit.
<div> content </div>
Can be anything because it is implemented using whatever element is passed to it in the constructor. Interesting because it generates FOCUSEVENTS and
KEYEVENTS.
Implemented as an IFRAME. Documented style name of
gwt-Frame is not implemented.
<iframe> </iframe>
Is just a table.
<table> <tbody> </tbody> </table>
Implemented as a DIV with default style name of
gwt-HTML. Can also set attribute
white-space to
normal or
nowrap.
<div class="gwt-HTML">html</div>
Is a DIV that can either contain HTML exactly as
HTMLor a collection of widgets. Does not use the
gwt-HTML style. The most useful attribute of an
HTMLPanel is that it contains the method
createUniqueId that returns an id of the form
HTMLPanel_N that can be used to apply styles to specific elements, as opposed to classes.
Contrast this with CheckBox which generates ids of the form
checkN without either the capitalization or the underscore. Not a bug, just another minor inconsistency.
<div> content </div>
Unsurprisingly this class is implemented as a TABLE. The most important things to know about
HTMLTable are (a) that it is the superclass for both
FlexTable and
Grid and (b) that it provides methods for setting the styles of individual rows or cells.
It is also worth noting that HTMLTable does not include a
THEAD. The 0th row therefore must be used as something of a pseudo-header by applying any necessary styles.
<table> <tbody> <tr>Row 0 -- if you want a header you have to fake it here.</tr> </tbody> </table>
// Style the first row to fake a header. table.getRowFormatter(0).setStyleName("something-interesting");
Implemented using a TABLE with all elements laid out as
TDs in a single
TR.
<table cell-spacing="0" cell-padding="0"> <tbody> <tr> <td style="display: static; vertical-align: top;" align="left">Item 1</td> <td style="display: static; vertical-align: top;" align="left">Item 2</td> </tr> </tbody> </table>
A DIV containing an anchor. Documented style name
gwt-HyperLink is not implemented.
Implemented as IMG. Documented style of
gwt-Image is not implemented.
<img src="..." />
Label is implemented as a
DIV with a default style name of
gwt-Label.
Labels do not interpret their content as HTML and by default allow word-wrap. If you want to use HTML content in your label then you should use an instance of
HTML. Both classes provide
MOUSEEVENTS.
You can change the default word-wrap by calling the setWordWrap method.
<div class="gwt-Label">your text here</div>
Implemented using SELECT with
OPTION for elements. Documented style name
gwt-ListBox is not implemented. Uses attributes
selected,
size, and
multiple as part of implementation.
Implemented as a DIV containing a
TABLE with menu items contained in
TD elements. A horizontal
MenuBar contains all menu items as children of a single
TR and a vertical
MenuBar uses a separate
TR for each item. Simple enough. The documented style name of
gwt-MenuBar is used and applied to the outer
DIV.
<div class="gwt-MenuBar"> <table> <tbody> <tr> <td class="gwt-MenuItem">text or html</td> <td class="gwt-MenuItem">text or html</td> </tr> <!-- example of a vertical menu <tr><td class="gwt-MenuItem">text or html</td></tr> <tr><td class="gwt-MenuItem">text or html</td></tr> --> </tbody> </table> </div>
A MenuItem is a
TD that can be inserted into a
MenuBar. The default style name is
gwt-MenuItem. A selected
MenuItem has the additional style name of
gwt-MenuItem-selected. I want to emphasize that the selected style is added to the default style, so that
class="gwt-MenuItem" becomes
class="gwt-MenuItem gwt-MenuItem-selected". This is not the case with all widgets and is another minor inconsistency in the GWT style design. See
StackPanel for an example of the opposite behavior.
Implemented as PASSWORD. Uses
gwt-PasswordTextBox.
Just a DIV.
Implemented as an instance of INPUT. Uses
gwt-RadioButton.
A RootPanel can be attached to any element, but it will discard all children previously belonging to that element. If you stop to think about it, this can be useful in contexts outside of your application init.
A DIV with
overflow set to
scroll or
auto. Defaults to
auto.
<div style="overflow: auto;"> content </div>
Just a DIV.
Implemented as a TABLE with 2 rows per item. In each pair of rows the first contains the caption and the second contains the corresponding widget. By default the
TABLE is styled with
gwt-StackPanel. The captions are styled with
gwt-StackPanelItem and
gwt-StackPanelItem-selected. When an item is selected the caption鈥檚 unselected style
gwt-StackPanelItem is replaced with
gwt-StackPanelItem-selected. Not all widgets behave this way. See
MenuItem for an example of the opposite behavior.
<table class="gwt-StackPanel" cell-spacing="0" cell-padding="0"> <tbody> <tr> <td class="gwt-StackPanelItem" height="1px">text/html</td> </tr> <tr> <td height="100%" valign="top"> content -- a widget </td> </tr> </tbody> </table>
A TabBar is implemented using a
HorizontalPanel so it is effectively a
TABLE. The style name
gwt-TabBar applies to the
TABLE 鈥?that is, to the actual tabs. The style
gwt-TabBarFirst applies to the first (effectively empty) HTML widget and is only useful for creating some sort of left border effect. The style
gwt-TabBarRest applies to that part of the
TabBar following the tabs.
When a tab is selected the style gwt-TabBarItem-selected gets added to the existing style. This behavior is like that of
MenuItem but opposite that of
StackPanel.
<table class="gwt-TabBar" cell-spacing="0" cell-padding="0"> <tbody> <tr> <td class="gwt-TabBarFirst" style="height: 100%;"><div class="gwt-HTML" style="height: 100%;">&nbsp;</div></td> <td>Tab #1</td> <td>Tab #2</td> <td class="gwt-TabBarRest" style="width: 100%;"><div class="gwt-HTML" style="height: 100%;">&nbsp;</div></td> </tr> </tbody> </table>
Implemented as a VerticalPanel containing a
TabBar and a
DeckPanel. In other words, it鈥檚 a bunch of nested tables. The style
gwt-TabPanel applies to the top-level
TABLE,
gwt-TabBar still applies to the contained
TABLE implementing the
TabBar, and
gwt-TabPanelBottom styles the
DIV containing the actual content.
Note that the TabBar gets the added default style of
width: 100%. This ensures that the
TabBar is as wide as the content panel and is the reason the
gwt-TabBarRest style is important. It鈥檚 all about how you want that empty space to look.
<table class="gwt-TabPanel" cell-spacing="0" cell-padding="0"> <tbody> <tr> <td> <table class="gwt-TabBar" style="width: 100%;" cell-spacing="0" cell-padding="0"> <tbody> <tr> <td class="gwt-TabBarFirst" style="height: 100%;"><div class="gwt-HTML" style="height: 100%;">&nbsp;</div></td> <td class="gwt-TabBarRest" style="width: 100%;"><div class="gwt-HTML" style="height: 100%;">&nbsp;</div></td> </tr> </tbody> </table> </td> </tr> <tr> <td> <div class="gwt-TabPanelBottom"> </div> </td> </tr> </tbody> </table>
Implemented as a TEXTAREA with a default style of
gwt-TextArea.
<input type="text" class="gwt-TextBox" />
Implemented as a DIV containing nested
TreeItems. The style name
gwt-Tree applies to the
DIV and the style
overflow defaults to
auto.
<div class="gwt-Tree" style="overflow: auto;"> <div style="position: relative; margin-left: 16;" (handle)> <table> <tr> <td></td> <td></td> </tr> </table> </div> </div>
Implemented as a TABLE nested within a
DIV. The styles
gwt-TreeItem and
gwt-TreeItem-selected apply to the nested content element, a
SPAN. The selected state
gwt-TreeItem-selectedreplaces the unselected state
gwt-TreeItem, like
StackPanel but unlike
MenuItem or
TabBar.
<div style="position: relative; margin-left: 16; white-space: nowrap" (handle)> <table style="white-space: nowrap;"> <tr> <td style="vertical-align: middle;"><img src="tree_white.gif" /></td> <td style="vertical-align: middle;">content</td> </tr> </table> children </div>
Implemented using a TABLE with all elements laid out as
TRs.
<table cell-spacing="0" cell-padding="0"> <tbody> <tr><td style="display: static; vertical-align: top;" align="left">Item 1</td></tr> <tr><td style="display: static; vertical-align: top;" align="left">Item 2</td></tr> </tbody> </table>
綆楁硶瀹炵幇濡備笅錛?
1.棣栧厛鎸夌収浠ヤ笂緙栧彿瑙勫垯鍒濆鍖栦竴涓寘鍚?108 涓暟瀛楃殑鏁扮粍
2.姣忔闅忔満浠庤鏁扮粍涓娊鍙栦竴涓暟瀛楋紝鍒嗛厤緇欎繚瀛樼帺瀹舵暟鎹殑鏁扮粍
瀹炵幇璇ュ姛鑳界殑浠g爜濡備笅鎵紺猴細
import java.util.*;
/**
聽* 鍙戠墝綆楁硶鐨勫疄鐜?
聽* 瑕佹眰錛氭妸 2 鍓墝錛屼篃灝辨槸 108 寮狅紝鍙戠粰 4 涓漢錛岀暀 6 寮犲簳鐗?
聽*/
public class Exec {
聽聽聽 public static void main(String[] args) {
聽聽聽聽聽聽聽 // 瀛樺偍 108 寮犵墝鐨勬暟緇?br />聽聽聽聽聽聽聽 int[] total = new int[108];
聽聽聽聽聽聽聽 // 瀛樺偍鍥涗釜鐜╁鐨勭墝
聽聽聽聽聽聽聽 int[][] player = new int[4][25];
聽聽聽聽聽聽聽 // 瀛樺偍褰撳墠鍓╀綑鐗岀殑鏁伴噺
聽聽聽聽聽聽聽 int leftNum = 108;
聽聽聽聽聽聽聽 // 闅忔満鏁板瓧
聽聽聽聽聽聽聽 int ranNumber;
聽聽聽聽聽聽聽 // 闅忔満瀵硅薄
聽聽聽聽聽聽聽 Random random = new Random();
聽聽聽聽聽聽聽 // 鍒濆鍖栨暟緇?br />聽聽聽聽聽聽聽 for (int i = 0; i < total.length; i++) {
聽聽聽聽聽聽聽聽聽聽聽 total[i] = (i + 1) % 54;
聽聽聽聽聽聽聽聽聽聽聽 // 澶勭悊澶у皬鐜嬬紪鍙?br />聽聽聽聽聽聽聽聽聽聽聽 if (total[i] == 0) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 total[i] = 54;
聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 // 寰幆鍙戠墝
聽聽聽聽聽聽聽 for (int i = 0; i < 25; i++) {
聽聽聽聽聽聽聽聽聽聽聽 // 涓烘瘡涓漢鍙戠墝
聽聽聽聽聽聽聽聽聽聽聽 for (int j = 0; j < player.length; j++) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 // 鐢熸垚闅忔満涓嬫爣
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ranNumber = random.nextInt(leftNum);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 // 鍙戠墝
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 player[j][i] = total[ranNumber];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 // 縐誨姩宸茬粡鍙戣繃鐨勭墝
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 total[ranNumber] = total[leftNum - 1];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 // 鍙彂鐗岀殑鏁伴噺鍑忓皯 1
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 leftNum--;
聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 // 寰幆杈撳嚭鐜╁鎵嬩腑鐨勭墝
聽聽聽聽聽聽聽 for (int i = 0; i < player.length; i++) {
聽聽聽聽聽聽聽聽聽聽聽 for (int j = 0; j < player[i].length; j++) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 System.out.print("聽 " + player[i][j]);
聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽 System.out.println();
聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 // 搴曠墝
聽聽聽聽聽聽聽 for (int i = 0; i < 8; i++) {
聽聽聽聽聽聽聽聽聽聽聽 System.out.print("聽 " + total[i]);
聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 System.out.println();
聽聽聽 }
}
[a-zA-Z0-9] 鍦ㄥ寘鍚殑瀛楃涓?, 鍖歸厤鍏朵腑涓涓?, 鍙尮閰?鈥?a!鈥?
(abc) 鍦ㄥ寘鍚殑瀛楃涓?, 閮借閫愪竴鍖歸厤 , 鑰屼笖鏈夐『搴?, 鍏跺疄灝辨槸璇?,() 閲岄潰灝辨槸涓涓瓧姝e垯寮?, 鍙尮閰?鈥?abc93鈥?
2. 琛ㄨ揪寮忎箣闂村崈涓囦笉鑳芥湁絀烘牸
3.鏋勯犳鏌?email鐨勬鍒欒〃杈懼紡
聽聽聽 /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/
鍦ㄤ竴涓畬鏁寸殑 email 鍦板潃涓湁涓変釜閮ㄥ垎 :
銆1. 鐢ㄦ埛鍚?( 鍦?'@' 宸﹁竟鐨勪竴鍒?),
銆2.'@',
銆3. 鏈嶅姟鍣ㄥ悕 ( 灝辨槸鍓╀笅閭i儴鍒?).
鐢ㄦ埛鍚嶅彲浠ュ惈鏈夊ぇ灝忓啓瀛楁瘝闃挎媺浼暟瀛?, 鍙ュ彿 ('.'), 鍑忓彿 ('-'), and 涓嬪垝綰?('_'). 鏈嶅姟鍣ㄥ悕瀛椾篃鏄鍚堣繖涓鍒?, 褰撶劧涓嬪垝綰塊櫎澶?.
鐜板湪 , 鐢ㄦ埛鍚嶇殑寮濮嬪拰緇撴潫閮戒笉鑳芥槸鍙ョ偣 . 鏈嶅姟鍣ㄤ篃鏄繖鏍?. 榪樻湁浣犱笉鑳芥湁涓や釜榪炵畫鐨勫彞鐐逛粬浠箣闂磋嚦灝戝瓨鍦ㄤ竴涓瓧絎︼紝濂界幇鍦ㄦ垜浠潵鐪嬩竴涓嬫庝箞涓虹敤鎴峰悕鍐欎竴涓尮閰嶆ā寮?:
聽聽聽 聽/^[\w-]+$/
鐜板湪榪樹笉鑳藉厑璁稿彞鍙風殑瀛樺湪 . 鎴戜滑鎶婂畠鍔犱笂 :
銆 /^[\w-]+(\.[\w-]+) * $/
涓婇潰鐨勬剰鎬濆氨鏄 : " 浠ヨ嚦灝戜竴涓鑼冨瓧絎︼紙闄や簡 . 錛夊紑澶?, 鍚庨潰璺熺潃 0 涓垨鑰呭涓?浠ョ偣寮濮嬬殑瀛楃涓?."
鐒跺悗鏄悗闈竴閮ㄥ垎 , 鍦ㄧ綉涓婃祦浼犵殑涓縐嶅仛娉曟槸 , 鍚庨潰鐨勪竴閮ㄥ垎鏄窡鍓嶉潰閭i儴鍒嗕竴鏍風殑 , 浣嗘槸鎴戣寰楁湁鐐逛笉濡?, 闅鵑亾 abc@abc 榪欐牱涔熺鍚堜竴涓?email 鍦板潃鏍煎紡鍚?? 鎴戣瘯榪囦笉灝戠殑緋葷粺 , 閮戒笉鍏佽榪欐牱杈撳叆鐨?, 蹇呴渶瑕佷綘杈撳叆濡?abc@abc.abc 榪欐牱鐨勬牸寮忔墠琛岋紟鎵浠ュ悗闈㈤儴鍒嗘槸鐣ユ湁涓嶅悓鐨勶紟
聽聽 \^[\w-]+(\.[w-]+) 錛?$\
涓婇潰鐨勬剰鎬濆氨鏄 : " 浠ヨ嚦灝戜竴涓鑼冨瓧絎︼紙闄や簡 . 錛夊紑澶?, 鍚庨潰璺熺潃 錛戜釜鎴栬呭涓?浠ョ偣寮濮嬬殑瀛楃涓?."
濂?. 鐜板湪鍙渶瑕佺敤 鈥滰鈥?鎶婁袱閮ㄥ垎榪炴帴 :
銆/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[w-]+)+$/
榪欏氨鏄畬鏁寸殑 email 璁よ瘉鍖歸厤妯″紡浜?, 鍦?JS 涓彧闇瑕佽皟鐢?
聽聽聽 reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[w-]+)+$/;
聽聽聽 reg.exec(input);
榪斿洖涓?true, 灝辨槸璇?input 鏄竴涓?email 鍦板潃 .聽
閫氳繃榪欑鏂規硶灝卞彲浠ュ緱鍒版槸鍚︿負 email 浜?!
聽