Bonjour,
J'ai un problème actuellement avec le widget Text de la librairie SWT d'Eclipse
Voici mon code
Quand j'écris quoique ce soit dans le champs Text, ça marche nickel mais quand je n'écris rien dans le champs Text, je rentre quand même dans la boucle "if". Je ne comprend pas pourquoi ça rentre dans la boucle if . Quelqu'un peut m'expliquer?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Text text = new Text( group ,SWT.BORDER); text.bound(50,50,200,100); text.setText(""); text.setToolTipText("-p="); text.addListener (SWT.Verify, new Listener () { public void handleEvent (Event e) { String string = e.text; char [] chars = new char [string.length ()]; string.getChars (0, chars.length, chars, 0); for (int i=0; i<chars.length; i++) { if (!('0' <= chars [i] && chars [i] <= '9')) { e.doit = false; return; } } } }); if ( text.getText() != "" ) { System.out.println( text.getToolTipText()+text.getText() );
Merci d'avance
Partager