Java Code Examples for com.codename1.ui.TextArea#setGrowByContent()

The following examples show how to use com.codename1.ui.TextArea#setGrowByContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpanButton.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor accepting default text
 */
public SpanButton(String txt) {
    setUIID("Button");
    setLayout(new BorderLayout());
    text = new TextArea(getUIManager().localize(txt, txt));
    text.setColumns(100);
    text.setUIID("Button");
    text.setGrowByContent(true);
    text.setEditable(false);
    text.setFocusable(false);
    text.setActAsLabel(true);
    setFocusable(true);
    removeBackground(text.getUnselectedStyle());
    removeBackground(text.getSelectedStyle());
    removeBackground(text.getPressedStyle());
    removeBackground(text.getDisabledStyle());
    actualButton = new Button();
    actualButton.setUIID("icon");
    addComponent(BorderLayout.WEST, actualButton);
    Container center = BoxLayout.encloseYCenter(text);
    center.getStyle().setMargin(0, 0, 0, 0);
    center.getStyle().setPadding(0, 0, 0, 0);
    addComponent(BorderLayout.CENTER, center);
    setLeadComponent(actualButton);
    updateGap();
}
 
Example 2
Source File: SpanLabel.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor accepting default text
 */
public SpanLabel(String txt) {
    setUIID("Container");
    setLayout(new BorderLayout());
    text = new TextArea(getUIManager().localize(txt, txt));
    text.setActAsLabel(true);
    text.setColumns(text.getText().length() + 1);
    text.setGrowByContent(true);
    text.setUIID("Label");
    text.setEditable(false);
    text.setFocusable(false);
    icon = new Label();
    icon.setUIID("icon");
    iconWrapper = new Container(new FlowLayout(CENTER, CENTER));
    iconWrapper.getAllStyles().stripMarginAndPadding();
    iconWrapper.add(icon);
    addComponent(BorderLayout.WEST, iconWrapper);
    addComponent(BorderLayout.CENTER, BoxLayout.encloseYCenter(text));
    updateGap();
}
 
Example 3
Source File: RSSReader.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private Container createRendererContainer() {
    Container entries = new Container(new BoxLayout(BoxLayout.Y_AXIS));
    entries.setUIID("RSSEntry");
    Label title = new Label();
    title.setName("title");
    title.setUIID("RSSTitle");
    entries.addComponent(title);
    TextArea description = new TextArea(2, 30);
    description.setGrowByContent(false);
    description.setName("details");
    description.setUIID("RSSDescription");
    description.setScrollVisible(false);
    entries.addComponent(description);
    if(iconPlaceholder != null) {
        Container wrap = new Container(new BorderLayout());
        wrap.addComponent(BorderLayout.CENTER, entries);
        Label icon = new Label();
        icon.setIcon(iconPlaceholder);
        icon.setUIID("RSSIcon");
        icon.setName("icon");
        wrap.addComponent(BorderLayout.WEST, icon);
        entries = wrap;
    }
    return entries;
}
 
Example 4
Source File: ProgressAnimationsSample.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.add(new Label("Hi World"));
    hi.add(new CommonProgressAnimations.CircleProgress());
    hi.add(new CommonProgressAnimations.LoadingTextAnimation());
    
    Label labelThatIsLoading = new Label("Loading...");
    
    hi.add(labelThatIsLoading);
    CommonProgressAnimations.CircleProgress.markComponentLoading(labelThatIsLoading);
    UITimer.timer(2000, false, hi, ()-> {
        labelThatIsLoading.setText("Found 248 results");
        CommonProgressAnimations.CircleProgress.markComponentReady(labelThatIsLoading);
    });
    
    Label anotherLabelThatIsLoading = new Label("Loading...");
    
    hi.add(anotherLabelThatIsLoading);
    CommonProgressAnimations.CircleProgress.markComponentLoading(anotherLabelThatIsLoading);
    UITimer.timer(4000, false, hi, ()-> {
        labelThatIsLoading.setText("Found 512 results");
        CommonProgressAnimations.CircleProgress.markComponentReady(anotherLabelThatIsLoading, CommonTransitions.createFade(300));
    });
    
    TextArea someText = new TextArea("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
    someText.setGrowByContent(true);
    someText.setRows(4);
    someText.setColumns(40);
    someText.setPreferredW(Display.getInstance().getDisplayWidth());
    hi.add(someText);
    CommonProgressAnimations.LoadingTextAnimation.markComponentLoading(someText).cols(40).rows(5);
    UITimer.timer(6000, false, hi, ()-> {
        CommonProgressAnimations.CircleProgress.markComponentReady(someText, CommonTransitions.createFade(300));
    });
    hi.show();
}