Results 1 to 3 of 3

Thread: High-Level Graphics in J2ME

  1. #1
    Join Date
    Sep 2010
    Posts
    66

    High-Level Graphics in J2ME

    Classes that can be used to create interfaces in our applications are:
    • high-level graphical components that derive from the class Screen (TextBox, List, Alert, and Form);
    • class Canvas and related items for custom graphics and event handling.

    Each MIDlet has a reference to an object of type Display that is used to manage the display of graphics and information supported by the terminal. To obtain an instance of this class using the static method getDisplay().

    Code:
    public class extends MIDlet HighUI 
    { 
    private Display display; 
    
    public HighUI () 
    { 
    super (); 
    display = Display.getDisplay (this); 
    } 
    // ..... 
    }
    The methods are the most interesting class Display setCurrent() and getCurrent() , we will see in practice used to manage the display of elements in the window. In particular setCurrent() allows you to view a specific content editing (force) the state of the display of the midlet. In addition, the class exposes methods to obtain information on the characteristics of the terminal display (number of colors, transparency levels supported number, etc.).

  2. #2
    Join Date
    Sep 2010
    Posts
    66

    Re: High-Level Graphics in J2ME

    Our midlet start showing a form in which to insert the name of a friend of ours and his three phone numbers. The class that we use to start with, is the class Form : the use of other objects that derive from Screen is similar to what we shall see below. Form is an object that contains a set of components, which are derived from Item , which may be added and then displayed and used in accordance with the features provided by the user. To enter the name and three phone numbers of our friend, use TextField , a component that allows you to enter data into a text field.

    Code:
    //... 
    
    private Display display; 
    
    private Form form; 
    private TextField name; 
    private TextField PHONE1; 
    private TextField Phone2; 
    private TextField phone3; 
    
    public HighUI () 
    { 
    function (); 
    display = Display.getDisplay (this); 
    form = new Form ("Contact"); 
    name = new TextField ("Name", null, 30, TextField.ANY); 
    PHONE1 = new TextField ("Tel1", null, 15, TextField.PHONENUMBER); 
    Phone2 = new TextField ("Tel2", null, 15, TextField.PHONENUMBER); 
    phone3 = new TextField ("Tel3", null, 15, TextField.PHONENUMBER); 
    form.append (name); 
    form.append (PHONE1); 
    form.append (Phone2); 
    form.append (phone3); 
    
    ..... 
    } 
    
    protected void startApp () throws MIDletStateChangeException 
    { 
    display.setCurrent (form); 
    } 
    
    // ...
    We create the object Form specifying the title and subsequent TextField :
    Code:
    PHONE1 = new TextField ("Tel1", null, 12, TextField.PHONENUMBER);
    The previous construct specifies:
    • the label text field ( eg Tel1: );
    • the initial contents of the field (eg, null indicates that it must be empty);
    • the maximum allowable size (eg 12);
    • any input constraints (eg TextField.PHONENUMBER to force the inclusion of a telephone number; TextField.ANY do not set constraints).

  3. #3
    Join Date
    Sep 2010
    Posts
    66

    Re: High-Level Graphics in J2ME

    Graphic objects allow you to manage any commands that the user may be given from the terminal. This is done by creating objects Command whose associated actions are handled by a class that implements the interface CommandListener.

    Code:
    public class extends MIDlet implements CommandListener HighUI 
    { 
    ...// 
    
    private Command exit; 
    private Command submit; 
    
    public HighUI () 
    { 
    ...// 
    submit = new Command ("Send", Command.OK, 1); 
    exit = new Command ("Exit", Command.EXIT, 1); 
    form.addCommand (submit); 
    form.addCommand (exit); 
    form.setCommandListener (this); 
    
    //... 
    } 
    
    // .. 
    }
    Whereas the command "submit" listed in the code above we can see that is instantiated with:
    • A label that appears ("Send");
    • The type of command (OK);
    • The priority that is useful to define the display order of operations when there are more than one;
    The class that implements the interface to "listen" command is our midlet:
    Code:
    public class extends MIDlet implements CommandListener HighUI
    whose method commandAction be recalled each time you press a button corresponding to a menu command.

Similar Threads

  1. Replies: 9
    Last Post: 18-12-2011, 12:14 PM
  2. Replies: 3
    Last Post: 21-11-2011, 12:21 PM
  3. MSI X340: The fan is always on a high level of noise
    By Dimensioner in forum Motherboard Processor & RAM
    Replies: 3
    Last Post: 16-03-2011, 06:23 AM
  4. What is the High Level Assembly Language?
    By Abbie in forum Windows Software
    Replies: 5
    Last Post: 19-03-2010, 02:29 AM
  5. Extremely high noise level
    By Daiwik in forum Overclocking & Computer Modification
    Replies: 5
    Last Post: 22-12-2008, 08:03 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,750,455,235.40235 seconds with 16 queries