Latest messages

722 topics, 2262 messages
Kuix technical support » HTML rendering

also .. dir="rtl" is not working for text area. could anyone please tell me what to do?

 

Thanks

Kuix technical support » screen.setCurrent() from a 2nd thread

Yes,memory leaks realy exist!,please read this code snipped in Worker.java:


                        for (runningTaskIndex = 0; runningTaskIndex < tasks.size(); ++runningTaskIndex)
                        {
                            task = (WorkerTask) tasks.elementAt(runningTaskIndex);
                            if (task.run())
                            {
                                tasks.removeElementAt(runningTaskIndex);
                                runningTaskIndex--;
                            }
                        }

We can see,if task.run() returns false,then the task will NEVER remove from the tasks list!!
but the setCurrent() method just modified can NOT direct return true,it will result some incomplete redrawing concern!
            WorkerTask repaintTask = new WorkerTask() {

                public boolean run() {
                    Kuix.getCanvas().repaint();
                    return false;
                }
            };
            Worker.instance.pushTask(repaintTask);

so, I give the following solution:

            Worker.instance.pushTask(new WorkerTask()
            {
                public boolean run()
                {
                    Kuix.getCanvas().repaint();
                    if (!isInWidgetTree())
                    {
                        return true;
                    }
                    return false;
                }
            });

if the screen widget not in widget tree(maybe removed from its parent),then the task can safely remove from tasks list.

BTW:pls forgive my poor English ;-)

Kuix general board » Image From Url

If you have an ID of picture, you can setImage for this by way:

1. Download Image from URL.

2. Get widget instance of Picture by ID

3. Set Image for widget.

 

Thanks!

Kuix technical support » Can not use in Eclipse 3.5.1 or higher

I want to use KUIX plug-in with eclipse 3.5.1 or higher. but i can not run with my project.

and show error like this below:

java.lang.NoClassDefFoundError: HelloWorld: org/kalmeo/kuix/core/KuixMIDlet 

at com.sun.midp.midlet.MIDletState.createMIDlet(+29)

at com.sun.midp.midlet.Scheduler.schedule(+52)

at com.sun.midp.main.Main.runLocalClass(+28)

at com.sun.midp.main.Main.main(+116)

 

Please, help me solve this problem.

Thank you for your supporting.

Kuix technical support » TextField editOnAllKeys attribute

Hello Guys,

 

I've been trying to use the attribute editOnAllKeys to create a TextField without the textarea buffer when I click at widget...

According the javadoc from this component,

 

The attribute  editOnAllKeys defines if the J2ME native edit dialog is opened 

when some key is pressed when the widget has the focus.

 

I'm checking the source code to try to find how to fix that bug, but, I didn't

find yet.

 

Can anybody help me?

 

Thanks,

Lucas

Kuix technical support » How we create Kuix Application in eclips

Hi All,

any one help me about eclips? how we create project in eclips with kuix frame work.

thanks

Kuix technical support » I can't create an application with Kuix (With Eclipse)

hi Tofu

I do the same, but still i have problem .Its show error like "The hierarchy of the type Project inconsistent"

and for KuixMidlet build path or cofigure path, but I already build path.

Thanks

Ayesha

 

Kuix technical support » How to use qwerty with kuix?

Dear all,

I using kuix to deploy app in my phone (Nokia E61i) but i keyboard not work. Please help me.

Thanks for all reply and sorry for my english.

MCR

Kuix technical support » how to scroll text in list?

hi there!

I have a list:

<screen title="MyApp">
    <container style="layout:borderlayout">
        <scrollPane  showscrollbar="true" >
            <scrollpaneScrollbar></scrollpaneScrollbar>
            <scrollpaneContainer style="layout:borderlayout">
            <list id="newsList">
                <_renderer>
                    <![CDATA[<listItem style=" padding: 2; align:left ;border: 0 0 1 0;border-color: #bde4fa;">
                    <_onAction>NewsListItem(@{newsID})</_onAction>
                    <container style="align:center;layout:gridlayout(1,1)">
                       <container style="align:left;layout:gridlayout(1,2)">
                           <text class="scrollText" style="font-size:medium; font-style: bold;">@{title}</text>
                            <text style="align:left;layout:inlinelayout(false,fill); font-size:medium; padding: 4 0 0 0 ">@{sub}</text>
                    </container>
                </container>
                    </listItem>]]>
                </_renderer>
                <_items>@{entry}</_items>
            </list>
            </scrollpaneContainer>
        </scrollPane>
    </container>
    <screenFirstMenu onAction="back" >Back</screenFirstMenu>
    <screenSecondmenu>
        Menu
        <menuPopup>
            <menuItem onAction="about" >About</menuItem>
                <menuItem onAction="exitConfirm" >Exit</menuItem>
        </menuPopup>
    </screenSecondmenu>
</screen>

------------------------------------------------------------------

How to scroll text class="scrollText" . When I focus the item in list?

Kuix technical support » Dynamic Progress Bar

Hi,

 

You will need to design your own protocol for communication between the device and the server. Have a look at the below response from server:

0;OK;16;MyDataFromServer

 

In this response from server '0' is the return code, 'OK' is the message, '16' is the lenght of the response in bytes. With this kind of protocol you will be able to tell how big you data is and implement a progress indicator.

 

Hope this helps.

Kuix general board » Load xml from server

is it possible to load the xml from a server. rather than local.i see the method load screan can take an input stream so could an xml file be placed on a server then loadedthru input stream.

Kuix technical support » util problem

hey , i wonder if you can help me to solve this problem ...

am using netbeans , & i downloaded the latest version of kuix (1.1.0 ) , but i faced an error that told me about some classes in the util couldn't be found , like Filter.java , BooleanUtil.java , MathFP.java , ETC
so i want you to upload ( all ) calsses of the (util ) & give me the link
NOTE : i downloaded the kuix 1.1.0 , 1.0.1 from your offecial site , also i found the same problem & the same errors ..

 

 

 

HELP ME PLEASE :'(

Kuix general board » Fixed TextField Size

Got it!

 

1) Create new  TextField and repalce by one below

2)_ I have only

         i ) overwriten -----    public Metrics getPreferredSize(int preferredWidth)

         ii  changed --------  protected String getDisplayedText()

         iii added utili method --------- private int getMaxSizeWidth() {

3) to specify min size for text

          i) on the xmal   <textfield style="min-size:200  0; ......." />

          ii) or on the css textfield {  min-size: 160 0;  }

4) To specify maxsize

                   i) use ither only the min size above as min and max .

                   ii )or use only the xml maxsize an as min and max. <textfield style="..."  maxsize="10"/>

              iii) or use both to specify min and max <textfield style="min-size:80  0; ......."  maxsize="20"/>

         Please note tha above specifies min as 10 (8*10) chars and max as 20 chars.

 

Enjoy,

 

 

 

/*
 * This file is part of org.kalmeo.kuix.
 *
 * org.kalmeo.kuix is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * org.kalmeo.kuix is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with org.kalmeo.kuix.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Creation date : 21 nov. 2007
 * Copyright (c) Kalmeo 2007-2008. All rights reserved.
 * http://www.kalmeo.org
 */
package org.kalmeo.kuix.widget;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.TextBox;

import org.kalmeo.kuix.core.Kuix;
import org.kalmeo.kuix.core.KuixConstants;
import org.kalmeo.kuix.util.Alignment;
import org.kalmeo.kuix.util.Color;
import org.kalmeo.kuix.util.Insets;
import org.kalmeo.kuix.util.Metrics;
import org.kalmeo.util.BooleanUtil;
import org.kalmeo.util.StringTokenizer;
import org.kalmeo.util.worker.Worker;
import org.kalmeo.util.worker.WorkerTask;

/**
 * This class represents a textfield. <br>
 * <br>
 * <strong>For further informations, visit the <a
 * href="http://www.kalmeo.org/files/kuix/widgetdoc/index.html"
 * target="new">Kuix widgets reference page</a></strong>.
 *
 * @author bbeaulant
 */
public class TextField extends Text implements CommandListener {

    // Allowed constraints
    public static final String ANY = "any";
    public static final String EMAILADDR = "emailaddr";
    public static final String NUMERIC = "numeric";
    public static final String PHONENUMBER = "phonenumber";
    public static final String DECIMAL = "decimal";
    public static final String URL = "url";
    public static final String PASSWORD = "password";
    public static final String SENSITIVE = "sensitive";
    public static final String NON_PREDICTIVE = "non_predictive";
    public static final String INITIAL_CAPS_WORD = "initial_caps_word";
    public static final String INITIAL_CAPS_SENTENCE = "initial_caps_sentence";
    // TextBox command
    private final Command validateCommand;
    private final Command cancelCommand;
    // The associated textBox
    private TextBox textBox;
    // TextBox's title
    private String title = null;
    // TextBox's maxSize
    private int maxSize = 1000;
    // TextBox's constraints
    private int constraints = javax.microedition.lcdui.TextField.ANY;
    // Define if the edit dialog is opened when a key is hit
    private boolean editOnAllKeys = true;
    // Tooltip
    private long tooltipTimer;
    private WorkerTask tooltipTask;
    private Text tooltipText;
    private boolean tooltipVisible;
    // The change method
    private String onChange;
    // Internal
    private String displayedText = null;

    /**
     * Construct a {@link TextField}
     */
    public TextField() {
        super(KuixConstants.TEXT_FIELD_WIDGET_TAG);

        // Create command to be sure that labels have the correct value
        validateCommand = new Command(Kuix.getMessage(KuixConstants.VALIDATE_I18N_KEY), Command.OK, 1);
        cancelCommand = new Command(Kuix.getMessage(KuixConstants.CANCEL_I18N_KEY), Command.BACK, 0);
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Text#setAttribute(java.lang.String, java.lang.String)
     */
    public boolean setAttribute(String name, String value) {
        if (KuixConstants.TITLE_ATTRIBUTE.equals(name)) {
            setTitle(value);
            return true;
        }
        if (KuixConstants.MAX_SIZE_ATTRIBUTE.equals(name)) {
            setMaxSize(Integer.parseInt(value));
            return true;
        }
        if (KuixConstants.CONSTRAINTS_ATTRIBUTE.equals(name)) {
            constraints = javax.microedition.lcdui.TextField.ANY;
            StringTokenizer st = new StringTokenizer(value, ", ");
            while (st.hasMoreTokens()) {
                String constraint = st.nextToken();
                if (EMAILADDR.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.EMAILADDR;
                } else if (NUMERIC.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.NUMERIC;
                } else if (PHONENUMBER.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.PHONENUMBER;
                } else if (URL.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.URL;
                } else if (DECIMAL.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.DECIMAL;
                } else if (PASSWORD.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.PASSWORD;
                } else if (SENSITIVE.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.SENSITIVE;
                } else if (NON_PREDICTIVE.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.NON_PREDICTIVE;
                } else if (INITIAL_CAPS_WORD.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.INITIAL_CAPS_WORD;
                } else if (INITIAL_CAPS_SENTENCE.equals(constraint)) {
                    constraints |= javax.microedition.lcdui.TextField.INITIAL_CAPS_SENTENCE;
                }
            }
            return true;
        }
        if (KuixConstants.EDIT_ON_ALL_KEYS_ATTRIBUTE.equals(name)) {
            setEditOnAllKeys(BooleanUtil.parseBoolean(value));
            return true;
        }
        if (KuixConstants.TOOLTIP_ATTRIBUTE.equals(name)) {
            setTooltip(value);
            return true;
        }
        if (KuixConstants.ON_CHANGE_ATTRIBUTE.equals(name)) {
            setOnChange(value);
            return true;
        }
        return super.setAttribute(name, value);
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @return the maxSize
     */
    public int getMaxSize() {
        return maxSize;
    }

    /**
     * @param maxSize the maxSize to set
     */
    public void setMaxSize(int maxSize) {
        this.maxSize = Math.max(1, maxSize);
        if (text != null && text.length() > maxSize) {
            setText(text);
        }
    }

    /**
     * @return the constraints
     */
    public int getConstraints() {
        return constraints;
    }

    /**
     * @param constraints the constraints to set
     */
    public void setConstraints(int constraints) {
        this.constraints = constraints;
    }

    /**
     * @return the editOnAllKeys
     */
    public boolean isEditOnAllKeys() {
        return editOnAllKeys;
    }

    /**
     * @param editOnAllKeys the editOnAllKeys to set
     */
    public void setEditOnAllKeys(boolean editOnAllKeys) {
        this.editOnAllKeys = editOnAllKeys;
    }

    /**
     * @return th tooltip
     */
    public String getTooltip() {
        if (tooltipText != null) {
            return tooltipText.getText();
        }
        return null;
    }

    /**
     * Define the {@link TextField} tooltip text.
     *
     * @param text
     */
    public void setTooltip(String text) {
        if (tooltipText == null) {
            tooltipText = new Text();
            tooltipText.parent = this;
            tooltipText.setStyleClass(KuixConstants.TEXT_FIELD_TOOLTIP_STYLE_CLASS);
        }
        tooltipText.setText(text);
    }

    /**
     * @return the onChange
     */
    public String getOnChange() {
        return onChange;
    }

    /**
     * @param onChange the onChange to set
     */
    public void setOnChange(String onChange) {
        this.onChange = onChange;
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.FocusableWidget#isFocusable()
     */
    public boolean isFocusable() {
        return enabled && focusable;
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.AbstractTextWidget#setText(java.lang.String)
     */
    public TextWidget setText(String text) {
        displayedText = null;
        return super.setText(text != null ? text.substring(0, Math.min(text.length(), maxSize)) : null);
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.AbstractTextWidget#getDisplayedText()
     */
    protected String getDisplayedText() {

        int maxSizeWidth = getMaxSizeWidth();
        if ((constraints & javax.microedition.lcdui.TextField.PASSWORD) == javax.microedition.lcdui.TextField.PASSWORD) {
            if (displayedText == null && text != null) {
                StringBuffer buffer = new StringBuffer();
                for (int i = 0; i < text.length(); ++i) {
                    buffer.append('*');
                }
                displayedText = buffer.toString();
            }
//            return displayedText;
            return (displayedText == null) ? "" : displayedText.length() > maxSizeWidth ? displayedText.substring(0, maxSizeWidth - 1)
                    : displayedText;
        }
        // return super.getDisplayedText();

        return (text == null) ? "" : text.length() > maxSizeWidth ? text.substring(0, maxSizeWidth - 1)
                : text;
    }

    private int getMaxSizeWidth() {
        Metrics minSize = getMinSize();
        // get max(text minSize.width, maxSizeWidth (if mazSize is set. (note default is 1000)))
        // maxsize is in number of chars, while width is nuber is chars* 8
        //that is why I convert to check
        return (maxSize >= 1000) ? minSize.width
                : (maxSize * 8 < minSize.width) ? minSize.width
                : maxSize * 8;
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Widget#getPreferredSize(int)
     */
    public Metrics getPreferredSize(int preferredWidth) {
        Metrics metrics = getCachedMetrics();

        if (needToComputePreferredSize(preferredWidth)) {
            //calculate boundry size
            Insets insets = getInsets();
            metrics.width = insets.left + insets.right;
            metrics.height = insets.top + insets.bottom;


            Font font = getFont();
            if (font != null) {
                // get max(text minSize.width, maxSizeWidth)
                int maxSizeWidth = getMaxSizeWidth();
                //specified minsize
                Metrics minSize = getMinSize();
                // if  text fond width is smaller than minSize.width make sise minSize.width; else limit to maxSizeWidth
                metrics.width += font.stringWidth(getText() + "") < minSize.width ? minSize.width : maxSizeWidth;

                metrics.height += font.getHeight();
            }
        }
//        System.out.println(" E- metrics.width" + metrics.width);
//        System.out.println(" E-metrics.height" + metrics.height);
//        System.out.println(" mazSize" + maxSize);
//
//        System.out.println(" \n \n");

        return metrics;
    }


    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Widget#doLayout()
     */
    protected void doLayout() {
        super.doLayout();
        if (tooltipText != null) {
            Metrics preferredSize = tooltipText.getPreferredSize(getWidth());
            int x = Alignment.CENTER.alignX(getWidth(), preferredSize.width);
            int y = Alignment.CENTER.alignY(getHeight(), preferredSize.height);
            tooltipText.setBounds(x, y, preferredSize.width, preferredSize.height);
        }
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Text#paint(javax.microedition.lcdui.Graphics)
     */
    public void paint(Graphics g) {
        super.paint(g);
        paintBorder(g);
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Text#paintChildrenImpl(javax.microedition.lcdui.Graphics)
     */
    protected void paintChildrenImpl(Graphics g) {
        super.paintChildrenImpl(g);
        if (isFocused()) {
            Color color = getColor();
            if (color != null) {
                g.setColor(color.getRGB());
            } else {
                g.setColor(0x000000);
            }
            g.setStrokeStyle(Graphics.SOLID);
            g.drawLine(textX, textY, textX, textY + insetHeight - 1);
        }
        if (tooltipText != null && tooltipVisible) {
            tooltipText.paintImpl(g);
        }
    }

    /* (non-Javadoc)
     * @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command, javax.microedition.lcdui.Displayable)
     */
    public void commandAction(Command command, Displayable displayable) {
        if (command == validateCommand) {
            String textBoxString = textBox.getString();
            hideTooltip();
            boolean changed = textBoxString != null && !textBoxString.equals(getText());
            setText(textBoxString);
            if (changed && onChange != null) {
                Worker.instance.pushTask(new WorkerTask() {

                    public boolean run() {
                        Kuix.callActionMethod(Kuix.parseMethod(onChange, TextField.this));
                        return true;
                    }
                });
            }
        }
        Display.getDisplay(Kuix.getCanvas().getInitializer().getMIDlet()).setCurrent(Kuix.getCanvas());
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.AbstractFocusableWidget#processPointerEvent(byte, int, int)
     */
    public boolean processPointerEvent(byte type, int x, int y) {
        if (isEnabled() && type == KuixConstants.POINTER_RELEASED_EVENT_TYPE) {
            processActionEvent();
        }
        return super.processPointerEvent(type, x, y);
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Widget#processKeyEvent(byte, int)
     */
    public boolean processKeyEvent(byte type, int kuixKeyCode) {
        if (isEnabled() && type == KuixConstants.KEY_PRESSED_EVENT_TYPE
                && (kuixKeyCode == KuixConstants.KUIX_KEY_FIRE
                || (editOnAllKeys
                && (kuixKeyCode == KuixConstants.KUIX_KEY_1
                || kuixKeyCode == KuixConstants.KUIX_KEY_2
                || kuixKeyCode == KuixConstants.KUIX_KEY_3
                || kuixKeyCode == KuixConstants.KUIX_KEY_4
                || kuixKeyCode == KuixConstants.KUIX_KEY_5
                || kuixKeyCode == KuixConstants.KUIX_KEY_6
                || kuixKeyCode == KuixConstants.KUIX_KEY_7
                || kuixKeyCode == KuixConstants.KUIX_KEY_8
                || kuixKeyCode == KuixConstants.KUIX_KEY_9
                || kuixKeyCode == KuixConstants.KUIX_KEY_STAR
                || kuixKeyCode == KuixConstants.KUIX_KEY_POUND
                || kuixKeyCode == KuixConstants.KUIX_KEY_PENCIL)))) {
            return processActionEvent();
        }
        return super.processKeyEvent(type, kuixKeyCode);
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Widget#processActionEvent()
     */
    public boolean processActionEvent() {

        // Setup TextBox properties
        textBox = new TextBox(title == null ? "" : title, text == null ? "" : text, maxSize, constraints);
        textBox.addCommand(validateCommand);
        textBox.addCommand(cancelCommand);
        textBox.setCommandListener(this);

        // Show TextBox
        Display.getDisplay(Kuix.getCanvas().getInitializer().getMIDlet()).setCurrent(textBox);

        return true;
    }

    /**
     * Hide the TextField tooltip
     */
    private void hideTooltip() {
        if (tooltipTask != null) {
            tooltipTimer = 0;
            tooltipTask = null;
            tooltipVisible = false;
        }
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Widget#onFocus(org.kalmeo.kuix.widget.Widget)
     */
    protected void onFocus(Widget focusedWidget) {
        super.onFocus(focusedWidget);
        if (focusedWidget == this && tooltipText != null) {
            if (tooltipTimer != 0) {
                tooltipTimer = System.currentTimeMillis();
            } else {
                tooltipTimer = System.currentTimeMillis();
                tooltipTask = new WorkerTask() {

                    /* (non-Javadoc)
                     * @see com.kalmeo.util.worker.WorkerTask#execute()
                     */
                    public boolean run() {
                        if (tooltipTimer == 0) {
                            return true;
                        }
                        if (System.currentTimeMillis() - tooltipTimer > 2000) {
                            tooltipVisible = true;
                            invalidateAppearance();
                            return true;
                        }
                        return false;
                    }
                };
                Worker.instance.pushTask(tooltipTask);
            }
        }
    }

    /* (non-Javadoc)
     * @see org.kalmeo.kuix.widget.Widget#onLostFocus(org.kalmeo.kuix.widget.Widget)
     */
    protected void onLostFocus(Widget focusedWidget) {
        super.onLostFocus(focusedWidget);
        hideTooltip();
    }
}

 

 

 

Kuix general board » Image From Url

Kuix picture does not support a remote image(from internet),watch the source yourself,that's really not difficult.For Kuix does not have any socket or connection functionality.Add it yourself if you want.That's easy.

Kuix general board » Fixed TextField Size

shappy please paste code or tell us what you changed.