Results 1 to 4 of 4

Thread: Gauge Class for creating Volume Bar

  1. #1
    Join Date
    Nov 2009
    Posts
    712

    Gauge Class for creating Volume Bar

    Hi, I want to create a Volume Bar with the use of Java. One of my friend told me that it is simple with the use of Gauge Class it is simple, but I don't know anything about the gauge class. So, will you please help me to know what is gauge class? I am waiting for your reply. It will help me if you give some examples related this. Please reply me as soon as possible.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Gauge Class for creating Volume Bar

    HI, I have read from the sun that the Gauge class "Implements a graphical display, such as a bar graph, of an integer value."

    Constructor:
    It is having a single constructor which must have following fields:
    * String label
    * boolean interactive
    * int maxValue
    * int initialValue

    The first parameter is used to create a label for the Gauge. The second parameter specifies whether or not the Gauge is interactive. For example, an interactive Gauge could be used as an interactive volume control.

    The Gauge class is used for the purpose of a graphical representation of integer values between zero and a maximum value specified by the third parameter to the constructor. The initial value that will be graphed is provided by fourth parameter. The maximum value and the current value are within the control of the MIDlet code.

    Restrictions:
    • It must not be interactive.
    • It must not be owned by another container.
    • It must not have any Commands.
    • It must not have an ItemCommandListener.
    • It must not have a label (that is, its label must be null).
    • Its preferred width and height must both be unlocked.
    • Its layout value must be LAYOUT_DEFAULT.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Gauge Class for creating Volume Bar

    The code given below will give you the Volume Bar with the use of Gauge Class. So, first understand it and then use it for your further use. So, you will able to use it if you need it future. So, take a look on it carefully.

    Code:
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    
    public class VolumeGauge extends MIDlet implements ItemStateListener, CommandListener
    {
    	private Form frm;
    	private Display dis;
    	private Command cmd;
    	private Gauge gauge;
    	private StringItem stritem;
    
    	public VolumeGauge()
    	{
    		gauge = new Gauge("Volume", true, 5, 2);
    		stritem = new StringItem(null, "[value]");
    		itemStateChanged(gauge);
    	}
    
    	public void startApp(){
    		Form frm = new Form("GaugeExample");
    		cmd = new Command("Exit", Command.EXIT, 0);
    		dis = Display.getDisplay(this);
    		frm.append(gauge);
    		frm.append(stritem);
    		frm.addCommand(cmd);
    		frm.setCommandListener(this);
    		frm.setItemStateListener(this);
    		dis.setCurrent(frm);
    	}
    
    	public void itemStateChanged(Item item)
    	{
    		if (item == gauge)
    		{
    			stritem.setText("Volume Label = " + gauge.getValue());
    		}
    	}
    
    	public void pauseApp()
    	{
    	}
    
    	public void destroyApp(boolean unconditional)
    	{
    		notifyDestroyed();
    	}
    
    	public void commandAction(Command c, Displayable s)
    	{
    		String label = c.getLabel();
    		if (label.equals("EXIT"))
    		{
    			destroyApp(false);
    		}			
    	}
    }

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

    Re: Gauge Class for creating Volume Bar

    Hi, I am not having more great knowledge about the gauge class, but As of MIDP 2.0, the Gauge class defines eleven methods. But the restricted nature of the Gauge class attached to an Alert, primarily only one of the eleven methods: setValue is mostly used. The following code is used to create the gauge and to display the current status:
    Code:
     
    gauge = new Gauge("Volume", true, 5, 2);
    sitem = new StringItem(null, "[value]");
    itemStateChanged(gauge);

Similar Threads

  1. Creating a generic class in dot net
    By Vedic in forum Software Development
    Replies: 4
    Last Post: 16-02-2011, 08:51 AM
  2. Creating a vector type of a class
    By Xmen in forum Software Development
    Replies: 5
    Last Post: 24-02-2010, 03:38 AM
  3. Creating graphical ftp client with Perl using class NET:: FTP
    By Udayachal in forum Software Development
    Replies: 6
    Last Post: 16-02-2010, 01:43 AM
  4. Creating an array from a class
    By Kingfisher in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 02:50 PM
  5. Vista Partitioning - Creating a new Volume
    By Bob in forum Vista Help
    Replies: 11
    Last Post: 12-12-2008, 04:49 AM

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,713,915,206.45376 seconds with 17 queries