ScreenInfo
You can use the ScreenInfo class to show status information consistently over all the screens of your application.
Design
![]()
In the above example we use several images for displaying the online status of the user. The design
is easy using the default screeninfo style:
screeninfo {
margin-top: -24;
margin-left: 10;
}
The ScreenInfo class uses internally an IconCustomItem for visualization. Please refer to that item's documentation for more information about design options.
Configuration
You need to activate the usage of the ScreenInfo element by setting the "polish.ScreenInfo.enable" variable to "true" in your build.xml script:
<variable name="polish.ScreenInfo.enable" value="true" />
Programming
Since there is only a single ScreenInfo element that spans over all screens of your application, all
you need to modify your ScreenInfo element are static methods of the ScreenInfo class.
In the default mode the ScreenInfo element allows the setting of the text (ScreenInfo.setText(String))
and image (ScreenInfo.setImage(Image)) that should be displayed. You can also
toggle the visibility by calling ScreenInfo.setVisible( boolean ). The following example exhanges the
image of the ScreenInfo depending on the online status of the user:
private void setStatus( int status ) {
String url;
switch (status) {
case STATUS_ONLINE: url = "/info_online.png"; break;
case STATUS_INVISIBLE: url = "/info_invisible.png"; break;
default: url = "/info_offline.png";
}
//#if polish.ScreenInfo.enable
try {
Image img = Image.createImage(url);
ScreenInfo.setImage( img );
} catch (IOException e) {
//#debug error
System.out.println("Unable to switch to status " + status + ": " + url + " could not be loaded" + e );
}
//#else
//#debug info
System.out.println("status set to " + status );
//#endif
}
For changing the design, you can also use the #style preprocessing directive when calling
ScreenInfo.setText(String) or
ScreenInfo.setImage(Image):
//#style statusAccessDenied
ScreenInfo.setText("Not Allowed!");
You can also directly change the fontcolor and the background of the ScreenInfo element by calling
ScreenInfo.setFontColor(int) and ScreenInfo.setBackground( Background ).
This usage is, however, not recommended.
You can use any GUI item including your own CustomItem as a ScreenInfo element by calling ScreenInfo.setItem( Item ).
Remember that you must not call any of the text- or image-related methods of the ScreenInfo element afterwards, since
these require the usage of an IconItem internally.