FileDocCategorySizeDatePackage
DisplayDeviceAccess.javaAPI DocJ2ME MIDP 2.02873Thu Nov 07 12:02:22 GMT 2002com.sun.midp.lcdui

DisplayDeviceAccess

public class DisplayDeviceAccess extends Object
Class that allows Display to access Device specific calls in the native code like vibrate and flashBacklight.

Fields Summary
private static Timer
timerService
The Timer to service TimerTasks.
private TimerTask
task
A TimerTask.
Constructors Summary
Methods Summary
private voidcancelTimer()
Cancel any running Timer.

        if (task != null) {
            task.cancel();
            task = null;
        }
    
public booleanflashBacklight(int duration)
Requests a flashing effect for the device's backlight.

param
duration the number of milliseconds the backlight should be flashed, or zero if the flashing should be stopped
return
true if the backlight can be controlled


                                             
        
	if (duration < 0) {
	    throw new IllegalArgumentException();
	}

	if (duration == 0) {
	    showBacklight(false);
	    cancelTimer();
	}

	// start timer
	setTimer(duration);
	return showBacklight(true);
    
private voidsetTimer(int duration)
Set a new timer.

param
duration the number of milliseconds the vibrator should be run


        cancelTimer();
        try {
            task = new TimerClient();
            // execute for the duration in milli seconds
	    timerService.schedule(task, duration);
        } catch (IllegalStateException e) {
            e.printStackTrace();
            cancelTimer();
        }
    
private native booleanshowBacklight(boolean on)
show Backlight

param
on true to turn on the backlight and false to turn it off
return
true, if backlight was shown.