« Quick Start » : différence entre les versions
(Page créée avec « === First start === In this page, we are going to see how to create quickly a frame incuding a button just to see how it is easy to do it using <font color=#556B2F>'''GEN... ») |
|||
Ligne 13 : | Ligne 13 : | ||
You could see this on the Package Explorer subwindow ... | You could see this on the Package Explorer subwindow ... | ||
[[File:QuickStart1.jpg | [[File:QuickStart1.jpg]] | ||
=== Adding dependencies === | === Adding dependencies === |
Dernière version du 15 décembre 2017 à 08:33
First start
In this page, we are going to see how to create quickly a frame incuding a button just to see how it is easy to do it using GENIUS.
After that, you just will have to follow the next pages to get explanations with more and more details and functionalities ...
To illustrate this example, we started using Eclipse environment but, of course, you are allowed to use any other environment to use GENIUS. Anyway, we considered that the user owns basic knowledege of Java langage and environment and we will not describe, for example, what is a class and how to create it !
Opening Eclipse and creating a project
First, we will have to create a Java project. Practically, it could be more interesting to create a Maven project, mainly to manage dependencies but we preferred to keep a basic Java project not to impose a solution.
You could see this on the Package Explorer subwindow ...
Adding dependencies
Then it will be mandatory to add GENIUS library and other dependencies. To do it, you will have to:
- activate the "Properties" subwindow,
- then selecting the "Java Build Path" option,
- going to the "Libraries" tab
- and finally adding libraries as "External jars"
Your project explorer must show this:
Adding the Java code
Now, you may import the following code ...
import fr.cnes.genius.exception.GException;
import fr.cnes.genius.lowLevel.GButton;
import fr.cnes.genius.lowLevel.GFrame;
import fr.cnes.genius.lowLevel.GPanel;
public class MyPanel extends GPanel {
private GButton but;
public MyPanel () {
but = new GButton("Button");
}
public void display() throws GException {
put(but);
}
public void generic() { }
public static void main(String[] args) {
MyPanel pan = new MyPanel();
GFrame frame = new GFrame("Test", pan);
frame.display();
}
};
Note that the import lines must be added (or refreshed) automatically, using the Ctrl-Shift-O Eclipse shortcut.
Your first GUI !
You will obtain this tiny frame including a button ...