Results 1 to 4 of 4

Thread: Alert Message in Java

  1. #1
    Join Date
    Jan 2009
    Posts
    48

    Alert Message in Java

    Hi, I want some or the other information regarding the Alert Message with the help of Java Programming Language. If anyone has details about this, then please forward that to me. I am waiting for your reply. So, please reply me if you have any such kind of information. I have basic knowledge about java and also about the alert message, but wanted to increase this knowledge. So, please help me to get more knowledge.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Alert Message in Java

    HI, Basically the alert messages are used to display specific information when something action has been taken by the user. It can have two different options such as OK and Cancel. An alert is a small screen that displays message to the user and waits for a given period of time until user chooses some option.

    Alert(java.lang.Stringtitle, java.lang.StringalertText, javax.microedition.lcdui.ImagealertImage, javax.microedition.lcdui.AlertTypealertType)
    :- Use this to construct a new Alert object with the given title, content title, string and image, and alert type.

    Alert(java.lang.String title, java.lang.String alertText, javax.microedition.lcdui.Image alertImage, javax.microedition.lcdui.AlertType alertType, Style style):- Use this to Constructs a new Alert object with the given title, content string and image, and alert type.

    Alert(java.lang.String title, Style style):- Use this to create a new, empty Alert object with the given title.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Alert Message in Java

    Alert messages is the message which is displayed to the user when he takes particular action. The message box gives either error or some helpful information. The Alert class have following methods:

    • addCommand(javax.microedition.lcdui.Command cmd)
    • animate(long currentTime, ClippingRegion repaintRegion)
    • commandAction(javax.microedition.lcdui.Command cmd, javax.microedition.lcdui.Displayable thisScreen)
    • createCssSelector()
    • getDefaultTimeout()
    • getImage()
    • getIndicator()
    • getString()
    • getTimeout()
    • getType()
    • removeCommand(javax.microedition.lcdui.Command cmd)
    • setCommandListener(javax.microedition.lcdui.CommandListener listener)
    • setCurrent(javax.microedition.lcdui.Display display, Alert alert, javax.microedition.lcdui.Displayable nextDisplayable)
    • setImage(javax.microedition.lcdui.Image img)
    • setImage(javax.microedition.lcdui.Image img, Style style)
    • setIndicator(Gauge indicator)
    • setIndicator(Gauge indicator, Style style)
    • setString(java.lang.String str)
    • setString(java.lang.String str, Style style)
    • setStyle(Style style)
    • setTimeout(int time)
    • setType(javax.microedition.lcdui.AlertType type)
    • showNotify()

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Alert Message in Java

    Hello, I am sending you the code which will give you more information regarding the alert message in java. The example below will give alert message with an image. So, I think this will give you some more knowledge about the alert message.
    Code:
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.*;
    
    public class Alert extends MIDlet implements CommandListener
    {
    	private Display dis;
    	public Form frm;
    	private Command ok,cancel,done;
    	private Image image, image1, image2;
    			
    	public Alert() 
    	{
    		frm = new Form("Techarena Alert");
    		cancel = new Command("Cancel", Command.CANCEL, 2);
    		ok = new Command("OK", Command.OK, 2);
    		try
    		{
    			image = Image.createImage("/logo.png");
    			image1 = Image.createImage("/front_left1_bad.png");
    			image2 = Image.createImage("/Congratulations-1.png");
    		}
    		catch(Exception e)
    		{
    			System.out.println(e.getMessage());
    		}		
    	}
    
     	public void startApp() 
    	{
    		dis = Display.getDisplay(this);
    		try
    		{
    			frm.append(image);
    		}
    		catch(Exception e)
    		{
    		}
    		frm.addCommand(cancel);
    		frm.addCommand(ok);
    		frm.setCommandListener(this);
    		dis.setCurrent(frm);
    	}
    
    	public void pauseApp() 
    	{
    	}
    
    	public void destroyApp(boolean unconditional) 
    	{
    		notifyDestroyed();
    	}
    
    	public void showMsg()
    	{
    		Alert success = new Alert("OK", "Alert Message Here!", image2, AlertType.INFO);
    		success.setTimeout(5000);
    		success.setImage(image2);
    		dis.setCurrent(success, frm);		
    	}
    
    	public void tryAgain() 
    	{
    		Alert error = new Alert("Cancel", "Alert Message Here!", image1, AlertType.INFO);
    		error.setTimeout(5000);
    		error.setImage(image1);
    		dis.setCurrent(error, frm);
    	}
    	
    	public void commandAction(Command c, Displayable d) 
    	{
    		String label = c.getLabel();
    		if(label.equals("Cancel")) 
    		{
    			tryAgain();
    		} 
    		else if(label.equals("OK")) 
    		{
    			showMsg();
    		} 
    	}
    }

Similar Threads

  1. repeating new message alert in nokia C6 – 01
    By Svana in forum Portable Devices
    Replies: 2
    Last Post: 28-08-2011, 03:59 PM
  2. Message alert from Facebook is disabled
    By Condolem in forum Technology & Internet
    Replies: 5
    Last Post: 19-06-2011, 07:27 AM
  3. No alert tone on new message in Nokia c7-00
    By UTTIYA in forum Portable Devices
    Replies: 4
    Last Post: 15-03-2011, 07:52 PM
  4. New message don’t give alert in E72
    By VENMANI in forum Portable Devices
    Replies: 4
    Last Post: 11-01-2011, 10:27 PM
  5. Java checkbox, onCheck alert
    By raviranch in forum Software Development
    Replies: 3
    Last Post: 19-05-2009, 05:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,033,517.51623 seconds with 17 queries