Whenever I enable the autosize mode on my components, the label text dissapears
final CheckBox checkBox = new CheckBox();
checkBox.setText(text);
//checkBox.setAutoSizeMode(true);
m_content.add(m_textModeLayout.createConstraint(), checkBox);
final PickerComponent pickerComponent = PickerComponent.createStrings(opciones);
final Label labelForComponent = pickerComponent.getEditor().getLabelForComponent();
labelForComponent.setText(text);
//labelForComponent.setAutoSizeMode(true);
pickerComponent.onTopMode(true);
final TextComponent textComponent = new TextComponent();
final Label labelForComponent = textComponent.getEditor().getLabelForComponent();
textComponent.labelAndHint(text);
labelForComponent.setText(text);
//labelForComponent.setAutoSizeMode(true);
textComponent.onTopMode(true);
The problem I´m facing is that some of the texts are really big and I need a way for those to be displayed.
Thanks!
Autosize mode won't work here due to the unique layout constraint which prevents us from knowing the available size beforehand. It will only work in a deterministic layout.
I would suggest rethinking your design and using a SpanLabel below the text component to represent the additional details. That way the text won't shrink "too much".
An alternative would be setting the label size of the text to a specific smaller size but that might make the text unreadable to some users and make things worse as a result.
Related
My problem is that I didn't find any way to properly add an icon near a TextComponent, inside a TextModeLayout, to mask/unmask a password.
It's a layout problem only, because the code of the ActionListener to mask/unmask the password works correctly at least in the Simulator (it's taken from Codename One - Mask and Unmask Password Field on iOS).
On iPhone skin, the InputComponents labels and text fields are not aligned correctly:
On Android skin, the text is not aligned correctly if it doesn't valide:
About my code, instead of adding the InputComponent (of the password) directly to the TextModeLayout container, I enclosed the InputComponent and the Button inside a BorderLayout, and then I added the BorderLayout container to the TextModeLayout container.
When you do that the text mode layout stops working for that component as it's unaware of the layout in the hierarchy. The hierarchy in the border layout is the responsibility of that layout.
The solution is to extend the TextComponent and add that functionality to Codename One. As a workaround we might be able to rely on the behavior of the current component since the field is already in a border layout component. So something like this might work:
TextField tf = myTextComponent.getField();
Container b = tf.getParent();
b.add(EAST, unmask);
When I use horizontalSpan image does not show, however when I use widthPercentage the image perfect shows up.
How can I span the ScaleImageLabel?
My code:
TableLayout tm=new TableLayout(4,6);
tm.setGrowHorizontally(true);
Container con=new Container(tm);
con.setScrollableY(true);
hi.add(BorderLayout.CENTER,con);
TableLayout.Constraint cs;
Image icon=profilbillede.scaled(800, -1);
ScaleImageLabel lb=new ScaleImageLabel(icon);
lb.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FIT);
con.add(tm.createConstraint().horizontalSpan(2),lb);
The code below works because I removed the span. A table needs to calculate column widths automatically unless you explicitly tell it the with of the column.
When you use span we don't know if the width applies to the 1st or 2nd column so it's ignored with the assumption that you have a reason for spanning and not using one column. In that case you would define the width in a different cell either via preferred size or via the width element.
As a side note there is no need to scale the image before adding it to the ScaledLabel you would be doing double the scaling which degrades the appearance of the image.
Form hi = new Form("Table", new BorderLayout());
TableLayout tm=new TableLayout(4,6);
tm.setGrowHorizontally(true);
Container con=new Container(tm);
con.setScrollableY(true);
hi.add(BorderLayout.CENTER,con);
TableLayout.Constraint cs;
Image icon=duke.scaled(800, -1);
ScaleImageLabel lb=new ScaleImageLabel(icon);
lb.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FIT);
con.add(tm.createConstraint(),lb);
hi.show();
Still on my sidemenu from there, I've resolve the non broking text with a custom function that modify the text.
Now I'm stuck with the width of the component. I've change it from a SpanLabel to a TextArea in order to have more control on it's behaviour, but here is my problem: the TextArea width is too large as shown on the screenshot (put a ContentContainer UIID on to see the space occupied by the TextArea).
As you can see, the first component has a too large TextArea. I've set the column count of the TextArea to the length of the firstRow + 1, but it doesn't seem to take it in account.
The component is BorderLayout with a non grow center ScaleImageLabel and the TextArea on south. Is it a way to have a better width for the TextArea ? I would have it aligned with the image and with the area wrapped close to the text, but I really don't know how to achieve this...
Thanks in advance !
My suggestion is to use GridLayout for equal sizes or TableLayout with constraints for varying sizes for left and right components. It will prevent the TextArea from growing beyond a limit.
An example will be:
//GridLayout
Container cont = GridLayout.encloseIn(4, cmpL1, cmpR1, cmpL2, cmpR2)
//OR
//TableLayout with Constraint
TableLayout tl = new TableLayout(2, 2);
Container cont = new Container(tl);
cont.add(tl.createConstraint().widthPercentage(50), cmpL1);
cont.add(tl.createConstraint().widthPercentage(50), cmpR1);
cont.add(cmpL2);
cont.add(cmpR2);
I am trying to add an Arabic bundle using this code:
resourceBudle = new HashMap<String, String>();
resourceBudle.put("Ok", "موافق");
resourceBudle.put("#rtl", "true");
resourceBudle.put("MainTitle", "عربتي");
UIManager.getInstance().setBundle(resourceBudle);
Now the MainTitle is a label which I have styled using a UIID in the theme designer. I have set font to large and alignment to center. Now when I try to create a form with a toolbar and set the titlecomponent of the tolbar to this label I dont get the Arabix text. Instead I get for each character a box with "X" inside it. It looks like there is an encoding issue but I am not sure why. Can You please help??!!
Ok Sorry i think the problem was with the system font that I used. I had to change the font to monospace for example or any other font that supports Arabic.
Thanks.
Must show a text that is greater than the component in which it is inserted. Currently, the text does not wrap automatically.
I've tried using the following components: Text, Label and Display Field
Have you tried a text that contains white space? A single word that is too long won't be wrapped ever, but multiple shorter, space-delimited words maybe will, depending on the component you use.
If you want to show a long text, use a container and put the text into the html configuration, and it will auto-wrap.
The components you named also have their usage, but not for simple long text:
text is from the draw package, and good for specialized formatting.
displayfield is good inside a form whenever you want to display (read-only) some value that is part of the record that you load into the form. displayfield won't wrap at all - try textareafield with readonly configuration for that.
label is good as the label of a form field, but only if used via the labelable mixin, which does most of the work. A label should make its content wrap around if you provide a fixed width or maxWidth, but it does not automatically adhere to the parent object layout.
you can simply add styles to extjs components (you can use any of them):
word-wrap: break-word;
There are some ways to apply custom css styles to ext's elements
style: {
"word-wrap": 'break-word'
}
Also you can do this:
Ext.get('txtElement').setStyle('word-wrap', 'break-word');