« GPanTest » : différence entre les versions
(Page créée avec « TBW ... Return to the introduction ↑ Go to the next page → ») |
Aucun résumé des modifications |
||
Ligne 1 : | Ligne 1 : | ||
[{{PathCurrentJavaDoc}}/fr/cnes/genius/utils/GPanTest.html GPanTest] is just an help to build a GUI where to test locally a widget class. And when we say testing, it is not only to have a static view of the widget but also testing all its functionalities like conditional display or even mathematical computation if any ! | |||
In fact, rather than to create a [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GFrame.html GFrame], then adding buttons to call for read, write, clear, and so on, it is easier to call directly the [{{PathCurrentJavaDoc}}/fr/cnes/genius/utils/GPanTest.html GPanTest]] class as explained below. | |||
Let us take the example given for [[Conditional_display|conditional display]] ... | |||
<syntaxhighlight lang="java"> | |||
public class myPanel extends GPanel { | |||
GButton but1; | |||
GButton but2; | |||
GButton but3; | |||
GCheckBox cb; | |||
public myPanel() { | |||
but1 = new GButton("Bouton 1"); | |||
but2 = new GButton("Bouton 2"); | |||
but3 = new GButton("Bouton 3"); | |||
cb = new GCheckBox("Display button 3"); | |||
} | |||
public void generic() throws GException { | |||
put(but1); | |||
put(but2); | |||
if ( cb.isSelected() ) { put(but3); } // Easy, isn't it ? | |||
put(cb); | |||
} | |||
public void display() throws GException { generic(); } | |||
} | |||
</syntaxhighlight> | |||
We will have just to add the following main method: | |||
<syntaxhighlight lang="java"> | |||
public static void main(String[] args) { | |||
myPanel test = new myPanel(); | |||
GPanTest panTest = new GPanTest("Test of myPanel", test); | |||
panTest .display(); | |||
} | |||
</syntaxhighlight> | |||
By executing this method, the widget will appear inside a Frame. Up to that level, there is not a great improvement thanks to calling directly [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GFrame.html GFrame]! | |||
But, if we add the GReadWrite and/or the GClear interface, the frame will include other buttons allowing to test all these functionalities. You will have also the possibility to specify the name of the file where data will be read or written ... | |||
<syntaxhighlight lang="java"> | |||
public class myPanel extends GPanel implements GReadWrite, GClear { | |||
... | |||
public static void main(String[] args) { | |||
myPanel test = new myPanel(); | |||
GPanTest panTest = new GPanTest("Test of myPanel", test, "myPanel.xml"); | |||
panTest .display(); | |||
} | |||
</syntaxhighlight> | |||
[[File:GPanTest.jpg]] | |||
[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]] | [[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]] | ||
[[Create_your_own_widget|Go to the next page →]] | [[Create_your_own_widget|Go to the next page →]] |
Version du 5 mai 2017 à 14:08
GPanTest is just an help to build a GUI where to test locally a widget class. And when we say testing, it is not only to have a static view of the widget but also testing all its functionalities like conditional display or even mathematical computation if any !
In fact, rather than to create a GFrame, then adding buttons to call for read, write, clear, and so on, it is easier to call directly the GPanTest] class as explained below.
Let us take the example given for conditional display ...
public class myPanel extends GPanel {
GButton but1;
GButton but2;
GButton but3;
GCheckBox cb;
public myPanel() {
but1 = new GButton("Bouton 1");
but2 = new GButton("Bouton 2");
but3 = new GButton("Bouton 3");
cb = new GCheckBox("Display button 3");
}
public void generic() throws GException {
put(but1);
put(but2);
if ( cb.isSelected() ) { put(but3); } // Easy, isn't it ?
put(cb);
}
public void display() throws GException { generic(); }
}
We will have just to add the following main method:
public static void main(String[] args) {
myPanel test = new myPanel();
GPanTest panTest = new GPanTest("Test of myPanel", test);
panTest .display();
}
By executing this method, the widget will appear inside a Frame. Up to that level, there is not a great improvement thanks to calling directly GFrame!
But, if we add the GReadWrite and/or the GClear interface, the frame will include other buttons allowing to test all these functionalities. You will have also the possibility to specify the name of the file where data will be read or written ...
public class myPanel extends GPanel implements GReadWrite, GClear {
...
public static void main(String[] args) {
myPanel test = new myPanel();
GPanTest panTest = new GPanTest("Test of myPanel", test, "myPanel.xml");
panTest .display();
}