Search in sources :

Example 86 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class TabsWithSpanLabelsTest method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Custom Tabs", new BorderLayout());
    Tabs tb = new Tabs(Component.TOP) {

        @Override
        protected Component createTab(String title, Image icon) {
            SpanButton custom = new SpanButton(title);
            custom.setName("SpanButton");
            custom.setIcon(icon);
            custom.setUIID("Container");
            custom.setTextUIID("mpiTabMetalUnSelected");
            custom.setIconPosition(BorderLayout.NORTH);
            return custom;
        }

        @Override
        public String getTabTitle(Component tab) {
            return ((SpanButton) tab).getText();
        }

        @Override
        public String getTabTitle(int index) {
            String TabTitle = "";
            try {
                for (int a = 0; a < getComponentCount(); a++) {
                    Container cnt = (Container) getComponentAt(a);
                    for (int b = 0; b < cnt.getComponentCount(); b++) {
                        if (cnt.getComponentAt(b).getName() != null && cnt.getComponentAt(b).getName().compareToIgnoreCase("SpanButton") == 0 && index == b) {
                            return getTabTitle(cnt.getComponentAt(b));
                        }
                    }
                }
            } catch (Exception g) {
                g.printStackTrace();
            }
            return TabTitle;
        }

        @Override
        public void setTabTitle(String title, Image icon, int index) {
            try {
                for (int a = 0; a < getComponentCount(); a++) {
                    Container cnt = (Container) getComponentAt(a);
                    for (int b = 0; b < cnt.getComponentCount(); b++) {
                        if (cnt.getComponentAt(b).getName() != null && cnt.getComponentAt(b).getName().compareToIgnoreCase("SpanButton") == 0 && index == b) {
                            SpanButton custom = (SpanButton) cnt.getComponentAt(b);
                            custom.setText(title);
                            return;
                        }
                    }
                }
            } catch (Exception g) {
                g.printStackTrace();
            }
        }

        @Override
        protected void setTabSelectedIcon(Component tab, Image icon) {
            ((SpanButton) tab).setPressedIcon(icon);
        }

        protected void selectTab(Component tab) {
            for (int a = 0; a < this.getComponentCount(); a++) {
                Container cmp1 = (Container) this.getComponentAt(a);
                int selIndex = this.getSelectedIndex();
                for (int b = 0; b < cmp1.getComponentCount(); b++) {
                    if (cmp1.getComponentAt(b).getName() != null && cmp1.getComponentAt(b).getName().startsWith("SpanButton") == true) {
                        if (selIndex == b) {
                            ((SpanButton) tab).setTextUIID("mpiTabMetalSelected");
                        } else {
                            ((SpanButton) cmp1.getComponentAt(b)).setTextUIID("mpiTabMetalUnSelected");
                        }
                    }
                }
            }
        }

        @Override
        protected void bindTabActionListener(Component tab, ActionListener l) {
            ((SpanButton) tab).addActionListener(l);
        }
    };
    tb.addSelectionListener(new SelectionListener() {

        @Override
        public void selectionChanged(int oldSelected, int newSelected) {
        }
    });
    tb.setTabUIID(null);
    Button btn = new Button("Any Button Action");
    tb.addTab("Tab 1", btn);
    tb.addTab("Really long\ntext in tab", new Label("T2"));
    tb.addTab("Tab 3", new Label("T3"));
    tb.addTab("Tab 4", new Label("T4"));
    hi.add(BorderLayout.CENTER, tb);
    hi.show();
}
Also used : IOException(java.io.IOException) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) SelectionListener(com.codename1.ui.events.SelectionListener)

Example 87 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class TextComponentSample2745 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", new TextModeLayout(2, 1));
    TextComponent cmp1 = new TextComponent().label("label1");
    TextComponent cmp2 = new TextComponent().label("label2");
    hi.add(cmp1);
    hi.add(cmp2);
    hi.show();
    cmp1.text("text1");
    cmp2.text("text2");
    hi.revalidateWithAnimationSafety();
    hi.repaint();
}
Also used : TextComponent(com.codename1.ui.TextComponent) Form(com.codename1.ui.Form) TextModeLayout(com.codename1.ui.layouts.TextModeLayout)

Example 88 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class SwipableContainerTest2766 method start.

public void start() {
    // TEST: SWIPEABLE CONTAINER ALSO SWIPES UNDERLYING CONTAINER AS WELL
    Form hi = new Form("Welcome", new BorderLayout());
    Container list = new Container(BoxLayout.y());
    for (int i = 0; i < 20; i++) {
        SwipeableContainer swip = new SwipeableContainer(null, new Label("SWIPE"), new Label("ListElement " + i + " + a lot of fill text to make the element span over several lines so the dragging of the underlying Swipeable is normally noticeable"));
        list.add(swip);
    }
    list.setScrollableY(true);
    Container cont = hi.getContentPane();
    cont.add(BorderLayout.CENTER, list);
    SwipeableContainer swip = new SwipeableContainer(null, new SpanLabel("SOUTHSWIPE"), new SpanLabel("SOUTH CONTAINER"));
    cont.add(BorderLayout.SOUTH, swip);
    hi.show();
}
Also used : Container(com.codename1.ui.Container) SwipeableContainer(com.codename1.ui.SwipeableContainer) BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) SpanLabel(com.codename1.components.SpanLabel) Label(com.codename1.ui.Label) SwipeableContainer(com.codename1.ui.SwipeableContainer) SpanLabel(com.codename1.components.SpanLabel)

Example 89 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class SwitchScrollWheelingIssue method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form f = new Form();
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    f.setScrollable(true);
    for (int x = 1; x < 100; x++) {
        Container cnt = new Container(new GridLayout(2));
        cnt.addAll(new Label("Line" + x), new Switch());
        f.add(cnt);
    }
    f.show();
}
Also used : Container(com.codename1.ui.Container) GridLayout(com.codename1.ui.layouts.GridLayout) Switch(com.codename1.components.Switch) Form(com.codename1.ui.Form) BoxLayout(com.codename1.ui.layouts.BoxLayout) Label(com.codename1.ui.Label)

Example 90 with Label

use of com.codename1.rad.models.Property.Label in project CodenameOne by codenameone.

the class SwitchTest2644 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Switch sw = new Switch();
    hi.add(new Label("Hi World"));
    hi.add(sw);
    hi.show();
}
Also used : Switch(com.codename1.components.Switch) Form(com.codename1.ui.Form) Label(com.codename1.ui.Label)

Aggregations

Label (com.codename1.ui.Label)129 Form (com.codename1.ui.Form)95 Button (com.codename1.ui.Button)50 BorderLayout (com.codename1.ui.layouts.BorderLayout)50 Container (com.codename1.ui.Container)49 Component (com.codename1.ui.Component)27 SpanLabel (com.codename1.components.SpanLabel)26 Style (com.codename1.ui.plaf.Style)24 BoxLayout (com.codename1.ui.layouts.BoxLayout)19 TextArea (com.codename1.ui.TextArea)18 ActionEvent (com.codename1.ui.events.ActionEvent)18 IOException (java.io.IOException)18 Image (com.codename1.ui.Image)17 Dimension (com.codename1.ui.geom.Dimension)16 TextField (com.codename1.ui.TextField)15 ActionListener (com.codename1.ui.events.ActionListener)15 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)15 Toolbar (com.codename1.ui.Toolbar)13 FlowLayout (com.codename1.ui.layouts.FlowLayout)12 EncodedImage (com.codename1.ui.EncodedImage)11