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

From: Jason Pollard <jasonpollard_at_yahoo.com>
Date: 09/18/03
Message-ID: <20030918084630.122.qmail@web9902.mail.yahoo.com>
> 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.

You can't extend the Component abstract class?  That would be the way to go if
you could.  Something like at the bottom.  If the gauge was a Component, you
could put it in your toolbox and use it anywhere you'd use another component. 
For example, you could:
aPanel.add(gauge)

This example isn't the best if code size is a problem for you.  But extending
Component would be more object oriented and reusable.



import com.nttdocomo.ui.*;
public final class gauge extends Component
{
    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();
    }

	public void setSize(int width, int height) {
        o_label_component.setSize( width,  height);
    }
    public void setForeground(int c) {
        o_label_component.setForeground( c);
    }
    public int getHeight() {
        return o_label_component.getHeight();
    }
    public int getY() {
        return o_label_component.getY();
    }
    public void setBackground(int c) {
        o_label_component.setBackground( c);
    }
    public void setLocation(int x, int y) {
        o_label_component.setLocation( x,  y);
    }
    public int getWidth() {
        return o_label_component.getWidth();
    }
    public void setVisible(boolean flag) {
        o_label_component.setVisible( flag);
    }
    public int getX() {
        return o_label_component.getX();
    }
...rest of your code here.

Hope that helps.

--jason

P.S. that was a very clever solution.


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Received on Thu Sep 18 11:45:25 2003