Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8024177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:47:17+00:00 2026-06-04T22:47:17+00:00

Please have a look at the following code First, Please note I am a

  • 0

Please have a look at the following code

First, Please note I am a 100% newbie to Java Mobile.

In here, I am making the light on and vibrate on when user click the button. However, I really wanted to create a SOS application which turn the whole screen into white, and go to black, like that, in the thread. I guess I didn’t achieve that by this app because even the lights are on, the buttons are still there. I tried to turn the “Form” color to “white” but it seems like JME has no “Color” class.

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Midlet extends MIDlet{

    private Form f;
    private Display d;
    private Command start,stop;
    private Thread t;

    public Midlet()
    {
        t = new Thread(new TurnLightOn());

    }

    public void startApp() 
    {
        f = new Form("Back Light On");


       d = Display.getDisplay(this);
       d.setCurrent(f);        

       start = new Command("Turn On",Command.OK,0);
       stop = new Command("Turn Off",Command.OK,1);

       f.addCommand(start);
       f.setCommandListener(new Action());



    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional)
    {
        this.notifyDestroyed();
    }

    private class Action implements CommandListener
    {

        public void commandAction(Command c, Displayable dis) 
        {
            f.append("Light is Turnning On");

            t.start();

        }

    }

     private class ActionOff implements CommandListener
    {

        public void commandAction(Command c, Displayable dis) 
        {


        }

    }

    private class TurnLightOn implements Runnable
    {

        public void run() 
        {
            f.append("Working");
            for(int i=0;i<100;i++)
            {

                try 
                {

                    d.flashBacklight(200);
                    d.vibrate(200);

                    Thread.sleep(1000);

                } 
                catch (InterruptedException ex)
                {
                    ex.printStackTrace();
                }
            }
        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:47:19+00:00Added an answer on June 4, 2026 at 10:47 pm
        public void startApp() 
            {
                f = new Form("Back Light On");
    
    
               d = Display.getDisplay(this);
    
    
               start = new Command("Turn On",Command.OK,0);
               stop = new Command("Turn Off",Command.OK,1);
    
               f.addCommand(start);
               f.setCommandListener(new Action());
    
        myCanvas = new MyCanvas();
         d.setCurrent(myCanvas);   
                myCanvas.repaint();
    
    }
    

    Now create a canvas and implement paint method like this:

      class MyCanvas extends Canvas {
                public void paint(Graphics g) {
                    // create a 20x20 black square in the center
    
                    // clear the screen first
                    g.setColor(0xffffff);
                    g.fillRect(0, 0, getWidth(), getHeight());
    
                    g.setColor(0xffffff); // make sure it is white color
    
                    // draw the square, <b>changed to rely on instance variables</b>
                    <b>g.fillRect(x, y, getWidth(), getHeight());</b>
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am new here. i have a slight problem; PLease look at the following code
Please have a look at following code : import java.util.ArrayList; import java.util.List; class Main{
Please have a look at the following code import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout;
Please have a look at the following code. import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.*;
Please have a look at the following code import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue;
Please have a look at the following code, which I have run in VB6
Please have a look at the following code: #include <stdio.h> #include <stdlib.h> typedef struct
Please have look on the following code: $_SESSION[process_y] = new Process(); $process_y = $_SESSION[process_y];
Please have a look a the following code sample, executed on a Windows-32 system
Please have a look at the following code: <HTML> <HEAD> <script src=//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js type=text/javascript></script> <SCRIPT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.