I solved it by a bit of hack, but it seems to work OK. In the attached 
file, when I instantiate my Painter, I save

top = f.getTitleComponent().getPreferredSize().getHeight();

and in the paint method

if (ypos < top) return;.




On Friday, January 20, 2017 at 3:00:08 PM UTC+10, Shai Almog wrote:
>
> I've ran into that to in the input demo in the kitchen sink with the 
> standard validation code. We need a good way to detect that, can you file 
> an issue on this
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/ff51ef2d-a67c-4ef9-b127-3771ccfbec38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.webbtide.utils;

import com.codename1.ui.Component;
import com.codename1.ui.Form;
import com.codename1.ui.Graphics;
import com.codename1.ui.Image;
import com.codename1.ui.Painter;
import com.codename1.ui.geom.Rectangle;
import com.codename1.ui.painter.PainterChain;
import java.util.ArrayList;

/**
 *
 * @author bryanb
 */
public class BJBValidatePainter implements Painter {

    private final ArrayList<Component> comps;
    private final Image cross = Utils.getCrossA();
    private final Image tick = Utils.getTickA();
    private Image image;
    private int top;

    public BJBValidatePainter(Form f) {

        comps = new ArrayList<>();
        top = f.getTitleComponent().getPreferredSize().getHeight();
        
        PainterChain.installGlassPane(f, this);
    }

    public void add(Component comp) {
        if (!comps.contains(comp)) {
            comps.add(comp);
        }
    }

    public void remove(Component comp) {
        if (!comps.contains(comp)) {
            comps.remove(comp);
        }
    }

    /**
     * Handles the glasspane
     */
    @Override
    public void paint(Graphics g, Rectangle rect) {

        for (Component comp : comps) {
            if (comp instanceof BJBValidatePicker) {
                BJBValidatePicker cc = (BJBValidatePicker) comp;
                if (cc.isShowTicks()) {
                    if (cc.getStatus()) {
                        image = tick;
                    } else {
                        image = cross;
                    }
                    paintMe(g, cc);
                }
            } else if (comp instanceof BJBValidateTextArea) {
                BJBValidateTextArea cc = (BJBValidateTextArea) comp;
                if (!cc.isEditable()) {
                    continue;
                }
                if (cc.isShowTicks()) {
                    if (cc.getStatus()) {
                        image = tick;
                    } else {
                        image = cross;
                    }
                    paintMe(g, cc);
                }
            }
        }

    }

    private void paintMe(Graphics g, Component comp) {

        int xpos = comp.getAbsoluteX();
        int ypos = comp.getAbsoluteY();
        float width = comp.getWidth();
//        float height = comp.getHeight();
        xpos += Math.round(width);
//        xpos -= 28;
//        ypos -= 28;

        xpos -= image.getWidth() - 6;
        ypos -= 6;
        if (ypos < top) return;

        g.drawImage(image, xpos, ypos);

    }

}

Reply via email to