GContainer

De GENIUS
Révision datée du 5 mai 2017 à 09:16 par Admin (discussion | contributions)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche

When we want to merge several basic widgets (for example several GEntryReal), we can encapsulate them inside a GPanel:

  • Advantage: directly displayed
  • Drawback: when created, we don’t know exactly how to display it

Another solution is to put these objects inside a GContainer

  • Drawback: it is not possible to display it directly
  • Advantages: display management will be done by the final user

We may use this GContainer several times inside a same GPanel (for example several Orbit parameters or several maneuvers laws).

Note that, unlike GPanel, one have to implement the GDisplay interface in order to be able to be displayed (by default, GPanel implements this interface).

// This class must implement the GDisplay interface in order to be abled to be displayed ...
public class MyContainer extends GContainer implements GDisplay {

  private GButton but1;
  private GButton but2;
  private GButton but3;

  public MyContainer () {
    but1 = new GButton("Button1");
    but2 = new GButton("Button 2");
    but3 = new GButton("Button 3");
  }

  public void generic() throws GException{
    put(but1);
    put(but2);
    put(but3);
  }

  public void display() throws GException {
    generic();
  }

}

Then this container will be called as is:

GPanel pan = new GPanel() {

  private MyContainer cont = new MyContainer();

  public void display() throws GException {
    generic();
  }

  public void generic() throws GException {
    put(cont);
  }

};


Return to the introduction ↑ Go to the next page →