MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

Java Programing laungage

J2ME Projects

J2ME Project 1

Creating a J2ME Application for addAlert into Form
Previous Home Next

AlertAn Alert is the dialog box displayed by your program to warn and show data to the user. It is generally used to inform the user about potential errors and other exceptional conditions such as interrupt, beak in communication and waits for a certain period of time before proceeding to the next Displayable. An alert may contain a text string and an image.

addAlert into Form

Alert alert= new Alert(title, alertText, alertImage, alertType)

title = display title of dialog box.

alertText = display text with contain information about alert

alertImage = display image with alert message into dialog box

alertType = user define what type of alert he required in program. Alert Type are - AlertType.ALARM, AlertType.CONFIRMATION, AlertType.ERROR, AlertType.INFO, AlertType.WARNING

Alert Program


/*
 * Save as a addAlert.java
 */
package r4r.Mobile.Basic;

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

/**
 * @author R4R
 */
public class addAlert extends MIDlet implements CommandListener {

    /* -- private field -- */
    private Form form;
    private Display display;
    private Alert alert;
    private Command exit, launch;

    /* -- Default constructor -- */
    public addAlert() {
        display = Display.getDisplay(this);
        form = new Form("Add Alert into form");
        exit = new Command("EXIT", Command.EXIT, 1);
        launch = new Command("LAUNCH", Command.OK, 1);
        form.addCommand(exit);
        form.addCommand(launch);
        form.setCommandListener(this);
    }

    public void startApp() {
        // Request to MIDlet for setting the current Displayable object be made visible on the display.
        display.setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == exit) {
            destroyApp(true);       // invoked MIDlet to terminate state
            notifyDestroyed();      // notify to MIDlet has entered into Destroyed state.
        } else if (c == launch) {
            activateAlert();              //invoked activeAlert() method
            form.removeCommand(launch);  // removes a command from the form

        }
    }

    /* -- call activeAlert() method into commandAction -- */
    private void activateAlert() {
        alert = new Alert(" Error ", " -- Alert Launch for 5000 milliseconds --  ", null, AlertType.ALARM);
        alert.setTimeout(5000);           //Set alert timeOut
        display.setCurrent(alert, form);
    }
}

 

output
Previous Home Next