Create and Display Alert Objects using java and netbeans

in utopian-io •  7 years ago  (edited)

Alert
Alert is a screen that displays data to the user and waits for a period of time before returning to the previous screen.

Alert Type:
Indicates the types of Alert objects to display.

Form
Form is a screen object that can be occupied by other items.

Work steps

  1. Opening Netbeans already installed.
    1.jpg

  2. Select File, then select New Project.
    2.jpg

  3. Next select Java ME in Categories
    3.jpg

  4. Then choose Mobile Application on Project.
    4.jpg

  5. Next press the Next button.
    5.jpg

  6. After that give the project name.
    6.jpg

  7. Then Select Platform in Device Configuration: CLDC-1.0 and Device Profile: MIDP-2.0.
    7.jpg

  8. Finish
    8.jpg

Program Files

Input :

import javax.microedition.midlet.;
import javax.microedition.lcdui.
;
public class Midlet extends MIDlet implements CommandListener {
private Display display;

to display on the desktop

private Form form;

create new coding

private Alert alert;

create for show alert

private Command cmdkeluar;

for command exit

private Command cmdalert;

public Midlet(){
display = Display.getDisplay(this);
form = new Form("Contoh Alert");
form.append("Contoh teks didalam form");
cmdkeluar = new Command("end",Command.EXIT,1);
cmdalert = new Command("alert",Command.SCREEN,2);

form.addCommand(cmdkeluar);
        form.addCommand (cmdalert);
form.setCommandListener(this);
}   

public void startApp() {
    display.setCurrent(form);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}


private void showAlert(){
        String info =   "ini adalah contoh pesan"+
                        "atau informasi yang akan"+
                        "disampaikan kepada user";
       # For show massage

alert = new Alert("Informasi",info,null,AlertType.ALARM);

alert.setTimeout(5000);
display.setCurrent(alert, form);
    }

public void commandAction(Command c,Displayable s){
if(c == cmdkeluar){
    destroyApp(true);
    notifyDestroyed();
}else if (c == cmdalert){   
    showAlert();
    }
}

}

Output :
o1.jpg
o2.jpg
o3.jpg

The Final Result

hasil.jpg

Analysis Program

In this experimental program 4 is a program that uses the Alert object, the following syntax used in this experiment.

  • private Alert alert;
    Syntax used as a Variable of Alert.

  • private Form form;
    This syntax is used as a Variable of the Form.

Conclusion

Alert is a screen that displays data to the user and waits for a period of time before returning to the previous screen.
Form is a screen object that can be occupied by other items.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved yet because it is not as informative as other contributions. See the Utopian Rules. Please edit your contribution and add try to improve the length and detail of your contribution (or add more images/mockups/screenshots), to reapply for approval.

  • Please remove the screenshots of code and instead insert them in a code box so that they may become readable.
  • Explain in detail the code used.
  • include proper headings and sub headings.
  • Explain what each step does.

You may edit your post here, as shown below:

You can contact us on Discord.
[utopian-moderator]

Ok, i have done fix my trouble , please re-check about my post and notice me if i need to fix another trouble

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @fakhriart I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • This is your first accepted contribution here in Utopian. Welcome!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x