The code for the Name Database application does not define names for the text fields. In lieu of names, JavaStar refers to them by their order--for example, textField1
, textField2
, and textField3
.
Ideally, the code would name the components. However, if the code you're testing uses default names for text fields, you can add your own by providing abstracted names in the declarations file. You do not have to do this in order to gain benefits from using declarations, but this provides an extra bonus. Using names makes scripts easier to modify, and logs easier to decipher. Updating the declarations to reflect GUI modifications is also more straightforward.
Note - When you change names in a declarations file, be sure to search to find any additional references to the original name, and update these, too.
Whether you use abstracted names or not, you always need to save and compile declarations after generating them. JavaStar creates on the .java
files when you generate declarations, not the .class
files.
MainWin.java
declarations file.NameData
subdirectory of tutorial
.
/* TextField */
public static JSComponent textField(){
return Namedb().member("java.awt.TextField", 0);
}
Note - The code to change and the replacement code is set in bold type for these examples. It won't appear in bold in the Script Editor window.
Change textField()
to nameTextField()
. Your code should read:
/* TextField */
public static JSComponent nameTextField(){
return Namedb().member("java.awt.TextField", 0);
}
textField2
with address1TextField
./* TextField */
public static JSComponent textField2(){
return Namedb().member("java.awt.TextField", 1);
}
/* TextField */
public static JSComponent address1TextField(){
return Namedb().member("java.awt.TextField", 1);
}
Note - When replacing "textField
", don't forget to include the number that follows it.
textField3
with address2TextField
.
Replace:
/* TextField */
public static JSComponent textField3(){
return Namedb().member("java.awt.TextField", 2);
}
/* TextField */
public static JSComponent address2TextField(){
return Namedb().member("java.awt.TextField", 2);
}
textField4
with emailTextField
./* TextField */
public static JSComponent textField4(){
return Namedb().member("java.awt.TextField", 3);
}
/* TextField */
public static JSComponent emailTextField(){
return Namedb().member("java.awt.TextField", 3);
}
textField5
with otherTextField
./* TextField */
public static JSComponent textField5(){
return Namedb().member("java.awt.TextField", 4);
}
/* TextField */
public static JSComponent otherTextField(){
return Namedb().member("java.awt.TextField", 4);
}
SearchWin.java
into the Script Editor./* TextField */
public static JSComponent textField(){
return SearchPop().member("java.awt.TextField");
}
textField()
to containsStrTextField()
.
/* TextField */
public static JSComponent containsStrTextField(){
return SearchPop().member("java.awt.TextField");
}
The Names window doesn't contain any text field components, so you don't need to edit the contents of NamesWin
. You do, however, need to compile the .java
file.
NamesWin.java
declarations file into the Script Editor.Send feedback to
JavaStar-feedback@suntest.com
Copyright © 1998
Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303.
All rights reserved.