Results 1 to 5 of 5
  1. #1
    gageqd is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default j2se AlertDemo problem...Help

    Error msg:
    Project settings saved
    Building "Alert"
    /root/j2mewtk/2.5.2/apps/Alert/src/AlertDemo.java:2: class or interface expected
    Alertw.setTimeout(5000);
    ^
    /root/j2mewtk/2.5.2/apps/Alert/src/AlertDemo.java:3: class or interface expected
    Alertw.setTimeout(Alert.FOREVER);
    ^
    2 errors
    com.sun.kvem.ktools.ExecutionException
    Build failed
    Java Code:
    Alertw.setTimeout(5000);
    Alertw.setTimeout(Alert.FOREVER);
    
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.*;
    public class AlertDemo extends MIDlet implements CommandListener
    {
      private Command exitCommand;
      private Display display;
      private String[] stringElements;
      private Image[] imageElements;
      private List selAlerm;
    
      public AlertDemo() throws IOException
    	{
    		
    		stringElements = new String[]{"ALARM","CONFIRMATION","ERROR","INFO","WARNING","FOREVER"};
    		display = Display.getDisplay(this);
    		exitCommand = new Command("leave",Command.EXIT , 1);
    	}
    	
    	public void startApp()
    	{
    		
    		selAlerm = new List("Alert DEMO",List.IMPLICIT,stringElements,imageElements);
    		selAlerm.addCommand(exitCommand);
    		selAlerm.setCommandListener(this);
    		display.setCurrent(selAlerm);
    	}
    	public void pauseApp(){}
    	public void destroyApp(boolean unconditional){}
    	public void commandAction(Command c , Displayable s)
    
    	{
    	   if (c == List.SELECT_COMMAND)
    	   {
    		switch(selAlerm.getSelectedIndex())
    		{
    			case 0:
    				{
    					Alert currentAlert = new Alert("Show Alert");
    					currentAlert.setString("this is a \"ALARM\"");
    					currentAlert.setType(AlertType.ALARM);
    					currentAlert.setTimeout(5000);
    					display.setCurrent(currentAlert);					
    				}break;
    			case 1:
    				{
    					Alert currentAlert = new Alert("Show Alert");
    					currentAlert.setString("This is a \"CONFIRMATION\"");
    					currentAlert.setType(AlertType.CONFIRMATION);
    					currentAlert.setTimeout(5000);
    					display.setCurrent(currentAlert);
    				}break;
    			case 2:
    				{
    					Alert currentAlert = new Alert("Show Alert");
    					currentAlert.setString("This is a \"ERROR\"");
    					currentAlert.setType(AlertType.ERROR);
    					currentAlert.setTimeout(5000);
    					display.setCurrent(currentAlert);
    				}break;
    			case 3:
    				{
    					Alert currentAlert = new Alert("Show Alert");
    					currentAlert.setString("This is a \"INFO\"");
    					currentAlert.setType(AlertType.INFO);
    					currentAlert.setTimeout(5000);
    					display.setCurrent(currentAlert);
    				}break;
    
    			case 4:
    				{
    					Alert currentAlert = new Alert("Show Alert");
    					currentAlert.setString("This is a \"WARNING\"");
    					currentAlert.setType(AlertType.WARNING);
    					currentAlert.setTimeout(5000);
    					display.setCurrent(currentAlert);
    				}break;
    			case 5:
    				{
    					Alert currentAlert = new Alert("Show Alert");
    					currentAlert.setString("This is a ALARM+FOREVER");
    					currentAlert.setType(AlertType.FOREVER);
    					display.setCurrent(currentAlert);
    				}break;
    				
    		}
    	   }
    			if(c==exitCommand)
    			{
    				destroyApp(false);
    				notifyDestroyed();
    			}
    	}
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: j2se AlertDemo problem...Help

    You need to start at the beginning. Copying code without understanding it at all isn't the way to learn.
    The Java™ Tutorials

    db

  3. #3
    gageqd is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Re: j2se AlertDemo problem...Help

    i had a book and i want to solve my problem , i am still learning , why don't you told me where I wrong and i correct it? please..

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: j2se AlertDemo problem...Help

    The error message is already telling you what's wrong and where. What are the first two lines of your posted code supposed to be there for any way? Why do you have them there?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: j2se AlertDemo problem...Help

    Moreover, the posted code uses classes from Java ME. It's not a Java SE AlertDemo .

    db

Similar Threads

  1. J2SE v.s. J2EE
    By vociferor in forum New To Java
    Replies: 3
    Last Post: 06-20-2011, 07:43 PM
  2. bluetooth on J2SE
    By Mekonom in forum New To Java
    Replies: 2
    Last Post: 12-26-2009, 10:05 PM
  3. Why to Use J2SE and Option for using this..
    By mgrprasad90 in forum Java Applets
    Replies: 0
    Last Post: 08-27-2008, 09:27 AM
  4. J2se, J2ee
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-13-2007, 10:33 AM
  5. Sdk & J2se
    By Gajesh Tripathi in forum New To Java
    Replies: 0
    Last Post: 10-18-2007, 07:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •