Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , , ,

Sponsored Links



Gauge Class for creating Volume Bar

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 10-12-2009
Member
 
Join Date: Nov 2009
Posts: 715
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.
Reply With Quote
  #2  
Old 10-12-2009
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,832
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.
Reply With Quote
  #3  
Old 10-12-2009
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,502
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);
		}			
	}
}
Reply With Quote
  #4  
Old 10-12-2009
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,937
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);
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Gauge Class for creating Volume Bar"
Thread Thread Starter Forum Replies Last Post
Creating a generic class in dot net Vedic Software Development 4 16-02-2011 08:51 AM
Creating a vector type of a class Xmen Software Development 5 24-02-2010 03:38 AM
Creating graphical ftp client with Perl using class NET:: FTP Udayachal Software Development 6 16-02-2010 01:43 AM
Creating an array from a class Kingfisher Software Development 3 25-11-2009 02:50 PM
Vista Partitioning - Creating a new Volume Bob Vista Help 11 12-12-2008 04:49 AM


All times are GMT +5.5. The time now is 04:03 AM.