2

I require some direction to incorporate gauge in J2ME which allows me to configure its minimum and maximum value, labels etc.

Currently, this is my gauge code:

levelGauge = new Gauge("Level", true, 12, valX - 16);

I am setting the maximum value as 12 (hence it becomes 0 to 12) but I need it to be from 16 to 28. The labels appear between 0 to 12 on movement.

Note I want the look and feel of the gauge which is ranging from 0 to 12 but should be from 16 to 28 actually. I do not want the current level of the gauge to go below 16 at any point of time.

gnat
  • 6,213
  • 108
  • 53
  • 73
Viraj
  • 1,880
  • 22
  • 31

1 Answers1

1

Straightforward way to have 16-to-28 gauge would be to use ItemStateListener.

For this, you'd use gauge with max value 28 and item state listener such that code in the itemStateChanged would check the value of the gauge and, if it is lower than 16, set it back to 16.

If you want to avoid displaying values lower than 16, consider some other options to do that, like CustomItem for your own "hand made" Gauge, or 3rd party UI libraries like LWUIT or J2ME Polish.

Community
  • 1
  • 1
gnat
  • 6,213
  • 108
  • 53
  • 73
  • Yes, But the minimum value will still be displayed as 0. I want the look and feel of the gauge which is ranging from 0 to 12 but should be from 16 to 28 actually. I do not want the current level of the gauge to go below 16 at any point of time. – Viraj Apr 02 '12 at 09:22
  • in that case, your options seem to be limited to CustomItem and 3rd party libraries like those I mentioned – gnat Apr 02 '12 at 10:20
  • @Viraj no problem - there is whole tutorial on that referred to at **[lcdui tag wiki](http://stackoverflow.com/tags/lcdui/info)** page - _Customizing Forms With CustomItems_ "demonstrates the MIDP 2.0 custom item capabilities..." – gnat Apr 02 '12 at 12:25