« GDialog and GDetachedPanel » : différence entre les versions

De GENIUS
Aller à la navigation Aller à la recherche
(Page créée avec « TBW ... Return to the introduction ↑ Go to the next page → »)
 
Aucun résumé des modifications
 
Ligne 1 : Ligne 1 :
TBW ...
<font color=#556B2F>'''GENIUS'''</font> proposes to display information in detached windows. Two objects may be used depending on the fact that the window has a modal comportment or not:
 
* [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDetachedPanel.html GDetachedPanel] if not modal
* [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDialog.html GDialog] if modal
 
The principle is more or less the same for both classes: we have to create a class extending [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDetachedPanel.html GDetachedPanel] or [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDialog.html GDialog] (as extending [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GPanel.html GPanel]):
 
<syntaxhighlight lang="java">
public class GDetachedPanelWidget extends GDetachedPanel {
private GLabel lab;
public GDetachedPanelWidget( String title ) {
super(title);
lab = new GLabel("GDetachedPanel test ...");
this.getJFrame().setPreferredSize(new Dimension(200, 100));
this.getJFrame().setLocation(200, 0);
}
@Override
public void display() throws GException {
generic();
}
@Override
public void generic() throws GException {
put(lab);
}
 
}
</syntaxhighlight>
 
<syntaxhighlight lang="java">
public class GDialogWidget extends GDialog {
private GLabel lab;
public GDialogWidget( String title ) {
super(title);
lab = new GLabel("GDialog test ...");
this.getJPanel().setPreferredSize(new Dimension(180, 60));
}
@Override
public void display() throws GException {
generic();
}
@Override
public void generic() throws GException {
put(lab);
}
 
}
</syntaxhighlight>
 
Then, the difference will be on the way to call them to be displayed:
 
* for [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDetachedPanel.html GDetachedPanel], it will be as for a [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GPanel.html GPanel] via the <font color=#4169E1>put()</font> method.
* for [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDialog.html GDialog], we will have to call for the <font color=#4169E1>display()</font> method of the object ; we will exit of this method when the [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDialog.html GDialog] window will have been closed.
 
<syntaxhighlight lang="java">
public class TestForGDialogAndGDetachedPanel extends GPanel {
private GCheckBox cbDialog;
private GCheckBox cbDetach;
 
private GDialogWidget dialog;
private GDetachedPanelWidget detach;
public TestForGDialogAndGDetachedPanel() {
cbDetach = new GCheckBox("Test GDetachedPanel");
cbDialog = new GCheckBox("Test GDialog");
detach = new GDetachedPanelWidget("GDetachedPanel");
dialog = new GDialogWidget("GDialog");
 
}
 
@Override
public void display() throws GException {
generic();
}
 
@Override
public void generic() throws GException {
put(cbDetach);
if ( cbDetach.isSelected() ) {
put(detach);
}
put(cbDialog);
if ( cbDialog.isSelected() ) {
dialog.show();
cbDialog.setSelected(false);
}
}
 
}
</syntaxhighlight>
 
Using the code above, we will have this:
 
 
[[File:GDetachedAndDialog1.jpg]]
 
 
by clicking on the checkbox for [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDetachedPanel.html GDetachedPanel]], a detached window will appear ...
 
 
[[File:GDetachedAndDialog2.jpg]]
[[File:GDetachedPanel.jpg]]
 
 
... and by clicking on the checkbox for [{{PathCurrentJavaDoc}}/fr/cnes/genius/lowLevel/GDialog.html GDialog], the following window will appear when the main window will be deactivated:
 
 
[[File:GDialog.jpg]]
 
 


[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
[[GContextFileManagement|Go to the next page →]]
[[GContextFileManagement|Go to the next page →]]

Dernière version du 5 mai 2017 à 13:56

GENIUS proposes to display information in detached windows. Two objects may be used depending on the fact that the window has a modal comportment or not:

The principle is more or less the same for both classes: we have to create a class extending GDetachedPanel or GDialog (as extending GPanel):

public class GDetachedPanelWidget extends GDetachedPanel {
	
	private GLabel lab;
	
	public GDetachedPanelWidget( String title ) {
		super(title);
		lab = new GLabel("GDetachedPanel test ...");
		this.getJFrame().setPreferredSize(new Dimension(200, 100));
		this.getJFrame().setLocation(200, 0);
	}
	
	@Override
	public void display() throws GException {
		generic();
	}
	
	@Override
	public void generic() throws GException {
		put(lab);
	}

}
public class GDialogWidget extends GDialog {
	
	private GLabel lab;
	
	public GDialogWidget( String title ) {
		super(title);
		lab = new GLabel("GDialog test ...");
		this.getJPanel().setPreferredSize(new Dimension(180, 60));
	}
	
	@Override
	public void display() throws GException {
		generic();
	}
	
	@Override
	public void generic() throws GException {
		put(lab);
	}

}

Then, the difference will be on the way to call them to be displayed:

  • for GDetachedPanel, it will be as for a GPanel via the put() method.
  • for GDialog, we will have to call for the display() method of the object ; we will exit of this method when the GDialog window will have been closed.
public class TestForGDialogAndGDetachedPanel extends GPanel {
	
	private GCheckBox cbDialog;
	private GCheckBox cbDetach;

	private GDialogWidget dialog;
	private GDetachedPanelWidget detach;
	
	public TestForGDialogAndGDetachedPanel() {
		
		cbDetach = new GCheckBox("Test GDetachedPanel");
		cbDialog = new GCheckBox("Test GDialog");
		
		detach = new GDetachedPanelWidget("GDetachedPanel");
		dialog = new GDialogWidget("GDialog");

	}

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

	@Override
	public void generic() throws GException {
		put(cbDetach);
		if ( cbDetach.isSelected() ) {
			put(detach);
		}
		put(cbDialog);
		if ( cbDialog.isSelected() ) {
			dialog.show();
			cbDialog.setSelected(false);
		}
	}

}

Using the code above, we will have this:


GDetachedAndDialog1.jpg


by clicking on the checkbox for GDetachedPanel], a detached window will appear ...


GDetachedAndDialog2.jpg GDetachedPanel.jpg


... and by clicking on the checkbox for GDialog, the following window will appear when the main window will be deactivated:


GDialog.jpg


Return to the introduction ↑ Go to the next page →