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

The following examples show how to use com.codename1.ui.TextArea#setRows() . 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: TextFieldCaretColorTest2780.java    From CodenameOne with GNU General Public License v2.0 6 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"));
    TextField tf1 = new TextField();
    TextField tf2 = new TextField();
    TextArea ta1 = new TextArea();
    TextArea ta2 = new TextArea();
    ta1.setRows(5);
    ta2.setRows(5);
    
    $(tf2, ta2).selectAllStyles()
            .setBgColor(0x0000ff)
            .setFgColor(0xffffff)
            .setBgTransparency(0xff)
            .setBackgroundType(Style.BACKGROUND_NONE);
    
    hi.addAll(tf1, tf2, ta1, ta2);
    hi.show();
}
 
Example 2
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();
}
 
Example 3
Source File: WebPushTest.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
void createPushForm() {
    Form f = new Form("Test Push", new BorderLayout());
    TextField serverUrl = new TextField("https://push.codenameone.com/push/push");
    String nexus5XEmulatorId = "cn1-fcm-c_t22hK-weg:APA91bGNa2hP9SHLBhUmLmzY1ANyjCH2ydEQz0JUFlMPFUHDAUfTQysC1r9K6I7jdk5LN6mEP5k5IWvyQX4dvubbHeY1KWQRKb-aYuXaHHHg2U3XGH1xXXa7xfJbsCf7nB0vu1aWhOg_4M4Z-znC2X5a0tpYf59QmA";
                              //APA91bHWiuoPMA4OgIr3ZyVgSjVmnh4H0BQ4jhB3hblIAZfmMs-SfRN1tb4662MudPEULjIkl8P_oTrQ14sKgowz4Q45n6iaPl1GwXb_9HbtlAQDAlnX60Eo4SamzZJkB_6kcnsEMKt_
    String iphoneId = "cn1-ios-c76b23de81f6389f37d2621f000b7f01c52e5c1d6f1f947b199a7c2d8844f713";
    
    
    TextArea targetId = new TextArea(Preferences.get("targetId", ""));
    targetId.addActionListener(e->Preferences.set("targetId", targetId.getText()));
    TextField pushType = new TextField(Preferences.get("pushType", "99"));
    pushType.addActionListener(e->Preferences.set("pushType", pushType.getText()));
    TextField payload = new TextField(Preferences.get("payload", "<push type=\"0\" body=\"Hello\" category=\"fo\"/>"));
    payload.addActionListener(e->Preferences.set("payload", payload.getText()));
    TextField gcmServerKey = new TextField(Preferences.get("gcmServerKey", ""));
    gcmServerKey.setHint("FCM_SERVER_API_KEY");
    gcmServerKey.addActionListener(e->Preferences.set("gcmServerKey", gcmServerKey.getText()));
    
    TextField tokenField = new TextField(Preferences.get("token", ""));
    tokenField.setHint("Enter your CN1 Token");
    tokenField.addActionListener(e->{
        Preferences.set("token", tokenField.getText());
    });
    
    targetId.setRows(4);
    targetId.getAllStyles().setFgColor(0x0);
    targetId.getAllStyles().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
    Button send = new Button("Send");
    send.addActionListener(e->{
        /*
        boolean result = new Push("E729F5CE-DCE8-4D63-B517-85112994EC66", payload.getText(), targetId.getText())
                .gcmAuth(gcmServerKey.getText())
                .apnsAuth(IOS_DEV_CERT_URL, IOS_DEV_CERT_PASS, false)
                .pushType(Integer.parseInt(pushType.getText()))
                .wnsAuth("xxxxx", "xxxxxxxx")
                .send()
                //.sendAsync()
                ;
        
        System.out.println("Push sent.  Result: "+result);
        */
        ConnectionRequest req = new ConnectionRequest();
        req.setUrl(serverUrl.getText());
        req.addArgument("token", tokenField.getText());
        req.addArgument("device", targetId.getText());
        req.addArgument("body", payload.getText());
        req.addArgument("type", pushType.getText());
        req.addArgument("auth", gcmServerKey.getText());
        req.addArgument("cert", IOS_DEV_CERT_URL);
        req.addArgument("certPassword", IOS_DEV_CERT_PASS);
        req.addArgument("sid", "ms-app://xxxxxxxxx");
        req.addArgument("client_secret", "xxxxxxxxx");
        req.setHttpMethod("POST");
        req.setPost(true);
        NetworkManager.getInstance().addToQueueAndWait(req);
        System.out.println(req.getResponseCode());
        try {
            System.out.println(new String(req.getResponseData(), "UTF-8"));
        } catch (Throwable t) {Log.e(t);}
               
        
        //new Push("E729F5CE-DCE8-4D63-B517-85112994EC66", payload.getText(), targetId.getText())
        //        .wnsAuth("ms-app://s-1-15-2-2674027049-292503787-1918612089-438606370-903203898-836476968-4131729547", "2S37cRtqCR3vQVqhfrFBA2w6PAsWwZ/m")
        //        .send();
        
    });
    
    Container center = BoxLayout.encloseY(new Label("Server URL"), serverUrl,
            new Label("Target ID"), targetId, new Label("Push Type"), pushType, new Label("Payload"), payload, new Label("GCM Server Key"), gcmServerKey, new Label("Codename One Token"), tokenField, send);
    center.setScrollableY(true);
    f.add(BorderLayout.CENTER, center);
    f.show();
    
}
 
Example 4
Source File: TextSelectionSample.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.setScrollableY(false);
    TextSelection sel = hi.getTextSelection();
    sel.addTextSelectionListener(e->{
        //System.out.println("Text selection has changed");
    });
    
    sel.setEnabled(true);
    Label label = new Label("This label should be selectable");
    label.setTextSelectionEnabled(true);
    Label label2 = new Label("Some more text");
    label2.setTextSelectionEnabled(true);
    hi.add(label);
    hi.add(new TextField("Hello Universe"));
    hi.add(label2);
    hi.add(new Label("Hi World"));
    
    Container cnt = new Container(BoxLayout.x());
    cnt.setScrollableX(true);
    cnt.getStyle().setBorder(Border.createLineBorder(1, 0x0));
    cnt.setPreferredH(CN.convertToPixels(5));
    cnt.setPreferredW(CN.convertToPixels(20));
    
    TextArea ta = new TextArea();
    ta.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.");
    ta.setEnabled(false);
    ta.setRows(6);
    hi.add(ta);
    
    SpanLabel sl = new SpanLabel();
    sl.setText(ta.getText());
    sl.setTextSelectionEnabled(true);
    hi.add(sl);
    
    
    TextField tf = new TextField();
    tf.setText("Hello World.  This is a test field");
    tf.setEnabled(false);
    hi.add(tf);
    
    Label l = new Label("This is a test with some long text to see if this works.  It should just flow when it runs out of space");
    l.setTextSelectionEnabled(true);
    cnt.add(l);
    
    Container cntY = new Container(BoxLayout.y());
    cntY.setScrollableY(true);
    cntY.getStyle().setBorder(Border.createLineBorder(1, 0x0));
    for (int i=0; i<50; i++) {
        Label li = new Label("List item "+i);
        li.setTextSelectionEnabled(true);
        cntY.add(li);
    }
    hi.add(cnt);
    hi.add(cntY);
    
    $(cnt, cntY).selectAllStyles().setMarginMillimeters(4);
    
    
    hi.show();
}
 
Example 5
Source File: UIFragmentSample.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private void testUIFragment() {
    Form f = new Form("Test Fragments", BoxLayout.y());
    TextArea ta = new TextArea();
    ta.setMaxSize(5000);
    
    String[] examples = new String[]{
        "<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>",
        
        "{centerAbs:$button1, south:{xng:[$button2, $button3, $button4]}}",
        
        "{cs:$button1, south:{xng:[$button2, $button3, $button4]}}",
        
        "{ca:$button1, south:{xng:[$button2, $button3, $button4]}}",
        
        "{centerScale:$button1, south:{xng:[$button2, $button3, $button4]}}",
        
        "{ctb:$button1, south:{xng:[$button2, $button3, $button4]}}",
        
        "{centerTotalBelow:$button1, south:{xng:[$button2, $button3, $button4]}}",
        
        "{s:$button1, c:{xng:[$button2, $button3, $button4]}}",
        
        "{s:$button1, c:{x:[$button2, $button3, $button4]}}",
        
        "{s:$button1, c:{y:[$button2, $button3, $button4]}}",
        
        "{s:$button1, c:{yBottomLast:[$button2, $button3, $button4]}}",
        
        "{s:$button1, c:{ybl:[$button2, $button3, $button4]}}"
        
        
        
        
    };
    
    ComboBox cb = new ComboBox(examples);
    cb.addActionListener(e->{
        ta.setText(examples[cb.getSelectedIndex()]);
    });
    
    ta.setText("<borderAbs><$button1 constraint='center'/><xng constraint='south'><$button2/><$button3/><$button4/></xng></borderAbs>");
    Button b = new Button("Compile");
    b.addActionListener(e->{
        Form f2 = new Form("Result", new BorderLayout());
        f2.setToolbar(new Toolbar());
        f2.setTitle("Result");
        f2.setBackCommand("Back", null, evt->{
            f.showBack();
        });
        f2.getToolbar().addCommandToLeftBar("Back", null, evt->{
            f.showBack();
        });
        Button b1 = new Button("Button 1");
        Button b2 = new Button("Button 2");
        Button b3 = new Button("Button 3");
        Button b4 = new Button("Button 4");
        $(b1, b2, b3, b4).selectAllStyles().setBorder(RoundRectBorder.create().cornerRadius(2)).setBgColor(0x003399).setBgTransparency(0xff);
        UIFragment frag;
        if (ta.getText().charAt(0) == '<') {
            frag = UIFragment.parseXML(ta.getText());
        } else {
            System.out.println("Parsing "+ta.getText());
            frag = UIFragment.parseJSON(ta.getText());
            
        }
        f2.add(BorderLayout.CENTER,frag 
                .set("button1", b1)
                .set("button2", b2)
                .set("button3", b3)
                .set("button4", b4)
                .getView()
        );
        f2.show();
    });
    ta.setRows(5);
    
    
    f.addAll(cb, ta, b);
    
    
    f.show();
}