Quick Start

De GENIUS
Révision datée du 15 décembre 2017 à 08:33 par Admin (discussion | contributions) (→‎Opening Eclipse and creating a project)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche

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 ...

QuickStart1.jpg

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,

QuickStart2.jpg

  • then selecting the "Java Build Path" option,
  • going to the "Libraries" tab
  • and finally adding libraries as "External jars"

QuickStart3.jpg

Your project explorer must show this:

QuickStart4.jpg

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 ...


QuickStart5.jpg