(keitai-l) Re: Creating new DoJa UI Components

From: Sam Joseph <gaijin_at_yha.att.ne.jp>
Date: 09/18/03
Message-ID: <3F694576.2090108@yha.att.ne.jp>
J. David Beutel wrote:

>On Thu, 18 Sep 2003, Sam Joseph wrote:
>  
>
>>I'm sure that the reason they have limited GUI components was to handle 
>>size restrictions on the 503s, but to prevent extendibility?  Well seems 
>>to me the only reason can be that they want to make it difficult for 
>>different GUIs to be presented, i.e. they want a TextBox to always have 
>>the same functionality that they have decided so as not to confuse the 
>>users.
>>    
>>
>
>I extended AWT a long time ago (before Swing).  One big limitation was 
>that many AWT classes are just proxies for native components.  In many 
>ways, they can't be extended.  It's not just a matter of access level.
>That was the price for the required speed and size.
>
>I wouldn't be surprised if the DoJa UI uses native components too.
>
Yeah - I think it may well do in some cases, although it does not in the 
emulator, although other parts of the emulator do use native c code to 
support them, e.g. for some lower level graphics operations and 
communications.

This makes me suspect that the DoJa UI components are actually java - 
but either way the point is moot; I can't extend them.

However I have managed to create a Gauge component (or ProgressBar) as 
it might be called, by cheating.

Well the thing is that I just started off trying to create a Gauge that 
was a modified Label - having been unable to extend either Label or 
Component, I created a Gauge class that included a Label inside it.

Now I have a Label wrapped by a Gauge class that updates itself like this:

  [wtkrun] label is now: ......................
  [wtkrun] .label is now: I.....................
  [wtkrun] .label is now: II....................
  [wtkrun] .label is now: III...................
  [wtkrun] .label is now: IIII..................
  [wtkrun] .label is now: IIIII.................
  [wtkrun] .label is now: IIIIII................
  [wtkrun] .label is now: IIIIIII...............
  [wtkrun] .label is now: IIIIIIII..............
  [wtkrun] .label is now: IIIIIIIII.............
  [wtkrun] .label is now: IIIIIIIIII............
  [wtkrun] .label is now: IIIIIIIIIII...........
  [wtkrun] .label is now: IIIIIIIIIIII..........
  [wtkrun] .label is now: IIIIIIIIIIIIII........
  [wtkrun] .label is now: IIIIIIIIIIIIIII.......
  [wtkrun] .label is now: IIIIIIIIIIIIIIII......
  [wtkrun] .label is now: IIIIIIIIIIIIIIIII.....
  [wtkrun] .label is now: IIIIIIIIIIIIIIIIII....
  [wtkrun] .label is now: IIIIIIIIIIIIIIIIIII...
  [wtkrun] .label is now: IIIIIIIIIIIIIIIIIIII..
  [wtkrun] .label is now: IIIIIIIIIIIIIIIIIIIII.
  [wtkrun] .label is now: IIIIIIIIIIIIIIIIIIIIII

A class so simple in fact that I've included it below - the only thing 
is that when you add it to a panel you have to do it like this:

aPanel.add(aProgressBar.getLabelComponent());

CHEERS> SAM


package dojaunit.ui;
import com.nttdocomo.ui.Label;

public final class Gauge
{
    private String label;
    private Label o_label_component = null;
    private int o_value = 0;
    private int o_max = 0;

    public Gauge(Object object, boolean b, int nCount, int p_value)
    {
        o_value = p_value;
        o_max = nCount;
        o_label_component = new Label();
        updateValue();
    }

    private void updateValue()
    {
        String x_text="";
        for(int i = 0;i<o_value;i++)
        {
            x_text += "I";
        }
        for(int i = o_value;i<o_max;i++)
        {
            x_text += ".";
        }
        System.out.println("label is now: " + x_text);
        o_label_component.setText(x_text);
    }

    public int getValue()
    {
        return o_value;
    }

    public void setValue(int p_value)
    {
        o_value = p_value;
        updateValue();
    }

    public void incrementValue()
    {
        o_value++;
        updateValue();
    }

    public Label getLabelComponent()
    {
        return o_label_component;
    }
}
Received on Thu Sep 18 08:40:10 2003