|
| |||||||||
| Tags: bar, class, gauge class, j2me, java, program, volume bar |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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
| ||||
| ||||
| 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:
|
|
#3
| ||||
| ||||
| 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
| ||||
| ||||
| 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); |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |