Move where Component displays

14 views
Skip to first unread message

Bryan Buchanan

unread,
Oct 29, 2016, 11:46:28 PM10/29/16
to CodenameOne Discussions
The image is two ValidateTextFields (in a grid, but that's not relevent). The code for a ValidateTextField is:

public class ValidateTextField extends Container {

   
Label label;
   
TextField textField;

   
public ValidateTextField() {
       
this("");
   
}

   
public ValidateTextField(String s) {

        setLayout
(new FlowLayout());
        setScrollableX
(false);
        setScrollableY
(false);
        setUIID
("BoldTextField");

        label
= new Label();
        label
.setUIID(null);
        label
.setText(null);
        label
.setIcon(null);
        label
.getAllStyles().setAlignment(Component.RIGHT);

        textField
= new TextField(s);
        textField
.setUIID(null);

        add
(LayeredLayout.encloseIn(textField, FlowLayout.encloseRight(label)));

   
}

   
public void setTick() {
        label
.setIcon(Utils.getTick());
   
}

   
public void setCross() {
        label
.setIcon(Utils.getCross());
   
}

The UIID for the container is basically an image border with a red border and which interior. What I'd like to do is have the tick and cross marks move to the top RHS cornerof the container, but can't figure out a way to do it.
Screenshot - 301016 - 13:38:39.png
Screenshot - 301016 - 13:44:00.png

Shai Almog

unread,
Oct 30, 2016, 9:28:58 PM10/30/16
to CodenameOne Discussions
setUIID(null) is probably a mistake.
You should give it a UIID and reduce the padding/margin on the top to 0.

However, it probably won't be much higher since the text field isn't very high to begin with. The validation framework can draw these partially outside of the component by using a glasspane or a layered layout.

Bryan Buchanan

unread,
Oct 31, 2016, 12:29:48 AM10/31/16
to CodenameOne Discussions
Thanks for the heads up on the validation framework. Have used the source to Validator to achieve just what I wanted.

Even though it's a battle sometimes because of the infinite flexibility, there's always a way with CN1 !
Screenshot - 311016 - 14:17:27.png
Reply all
Reply to author
Forward
0 new messages