Java Code Examples for javax.microedition.lcdui.Display#getDisplay()

The following examples show how to use javax.microedition.lcdui.Display#getDisplay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisplayEventHandlerFactory.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a reference to the singleton display manager object.
 *
 * @param token security token with the MIDP permission "allowed"
 *
 * @return display manager reference.
 */
public static DisplayEventHandler
        getDisplayEventHandler(SecurityToken token) {

    token.checkIfPermissionAllowed(Permissions.MIDP);

    if (managerImpl != null) {
        return managerImpl;
    }

    /**
     * The display manager implementation is a private class of Display
     * and is create in the class init of Display, we need to call a
     * static method of display to get the class init to run, because
     * some classes need to get the display manager to create a display
     */
    try {
        // this will yield a null pointer exception on purpose
        Display.getDisplay(null);
    } catch (NullPointerException npe) {
        // this is normal for this case, do nothing
    }

    return managerImpl;
}
 
Example 2
Source File: SocketStressBench.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
void runBenchmark() {
  Display display = Display.getDisplay(this);
  BouncyColors bouncyColors = new BouncyColors();
  display.setCurrent(bouncyColors);

  for (int i = 0; i < 16; i++) {
    Thread thread = new Thread(new Worker(), "T" + i);
    thread.setPriority(Thread.MIN_PRIORITY);
    thread.start();
  }

  Thread current = Thread.currentThread();
  current.setPriority(Thread.MAX_PRIORITY);

  while (true) {
    bouncyColors.repaint();
    try {
      Thread.sleep(16);
    } catch (InterruptedException e) {}
  }
}
 
Example 3
Source File: FileStressBench.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
public void startApp() {
    Display display = Display.getDisplay(this);
    BouncyColors bouncyColors = new BouncyColors();
    display.setCurrent(bouncyColors);

    for (int i = 0; i < 16; i++) {
        Thread thread = new Thread(new Worker(), "T" + i);
        thread.setPriority(Thread.MIN_PRIORITY);
        thread.start();
      }

    Thread current = Thread.currentThread();
    current.setPriority(Thread.MAX_PRIORITY);

    while (true) {
        bouncyColors.repaint();

        try {
            Thread.sleep(16);
        } catch (InterruptedException e) {}
    }
}
 
Example 4
Source File: Cottage360.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
protected void startApp() throws MIDletStateChangeException
{
	DeviceControl.setLights( 0, 100 );
	Display disp = Display.getDisplay( this );
	try
	{
		iCanvas = new PanoramaCanvas( Image.createImage(PHOTO_NAME), this );
		disp.setCurrent( iCanvas );
		iConnection = openAccelerationSensor();
		if (iConnection != null)
			iConnection.setDataListener( this, BUFFER_SIZE );
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
}
 
Example 5
Source File: BlogWriter.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public BlogWriter() {
    this.display = Display.getDisplay(this);
    // Crate login screen
    this.loginScreen = new LoginScreen(this.display);
    this.loginScreen.setParent(this);
    // Activate login screen
    this.display.setCurrent(this.loginScreen);
}
 
Example 6
Source File: Main.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
public void startApp() {
    if (display != null) {
        return;
    }

    self = this;
    display = Display.getDisplay(this);

    showLinksView(session.getCategory());
}
 
Example 7
Source File: AudioRecorder.java    From pluotsorbet with GNU General Public License v2.0 5 votes vote down vote up
protected void startApp() throws MIDletStateChangeException {
	this.recordButton = new StringItem(null, "Start", Item.BUTTON);
	Command toggleRecordingCMD = new Command("Click", Command.ITEM, 1);
	this.recordButton.addCommand(toggleRecordingCMD);
	this.recordButton.setDefaultCommand(toggleRecordingCMD);
	this.recordButton.setItemCommandListener(this);

	this.form = new Form(null, new Item[] {
			new StringItem(null, "Audio Recorder"), this.recordButton });

	this.display = Display.getDisplay(this);
	this.display.setCurrent(this.form);
}
 
Example 8
Source File: MIDlet.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
protected MIDlet() {
	Display.getDisplay(this); // init display for this instance
}
 
Example 9
Source File: GAFAControl.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
/** Separate initialization function for convenience. */
public void initialize() {
	display = Display.getDisplay(mainApp);
	myCanvas = new GAFAView(this, display);
	display.setCurrent(myCanvas);
}
 
Example 10
Source File: GAFAMidlet.java    From pluotsorbet with GNU General Public License v2.0 4 votes vote down vote up
/** Creates the midlet and initiates the display. */
public GAFAMidlet() {
	display = Display.getDisplay(this);
}
 
Example 11
Source File: MIDlet.java    From pluotsorbet with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Protected constructor for subclasses.
 * The application management software is responsible
 * for creating MIDlets and creation of MIDlets is restricted.
 * MIDlets should not attempt to create other MIDlets.
 *
 * @exception java.lang.SecurityException unless the application
 * management software is creating the MIDlet.
 */
protected MIDlet() {
    peer = MIDletStateHandler.newMIDletPeer(classSecurityToken, this);

    // Ensure that a display for this midlet is created
    Display d = Display.getDisplay(this);
}
 
Example 12
Source File: GAFAControl.java    From pluotsorbet with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set a view to the current display.
 * 
 * @param disp
 *            a view to set.
 */
public void setCurrent(Displayable disp) {
	if (display == null)
		display = Display.getDisplay(mainApp);
	display.setCurrent(disp);
}