com.codename1.ui.layouts.BorderLayout Java Examples

The following examples show how to use com.codename1.ui.layouts.BorderLayout. 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: ExecuteAndReturnStringTest.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", new BorderLayout());
    final BrowserComponent cmp = new BrowserComponent();
    cmp.setPage("<!doctype html><html><body>Hello World</body></html>", null);
    Button btn = new Button("Get User Agent");
    btn.addActionListener(evt->{
        ToastBar.showInfoMessage(cmp.executeAndReturnString("navigator.userAgent"));
    });
    hi.add(CENTER, cmp);
    hi.add(NORTH, btn);
    hi.show();
}
 
Example #2
Source File: TooltipManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Shows the actual tooltip, this is invoked when the time for the tooltip
 * elapses. It shows the tooltip UI immediately
 * 
 * @param tip the tooltip text
 * @param cmp the component
 */
protected void showTooltip(final String tip, final Component cmp) {
    currentTooltip = new InteractionDialog(new BorderLayout());
    
    TextArea text = new TextArea(tip);
    text.setGrowByContent(true);
    text.setEditable(false);
    text.setFocusable(false);
    text.setActAsLabel(true);
    text.setUIID(textUIID);
    currentTooltip.setUIID(dialogUIID);
    currentTooltip.setDialogUIID("Container");
    currentTooltip.add(BorderLayout.CENTER, text);
    currentTooltip.setAnimateShow(false);
    currentTooltip.showPopupDialog(cmp, true);
}
 
Example #3
Source File: ReactDemo.java    From codenameone-demos with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    placeholder = EncodedImage.createFromImage(Image.createImage(53, 81, 0), false);
    Form react = new Form("React Demo", new BorderLayout());
    react.add(BorderLayout.CENTER, new InfiniteContainer() {
        public Component[] fetchComponents(int index, int amount) {
            try {
                Collection data = (Collection)ConnectionRequest.fetchJSON(REQUEST_URL).get("movies");
                Component[] response = new Component[data.size()];
                int offset = 0;
                for(Object movie : data) {
                    response[offset] = createMovieEntry(Result.fromContent((Map)movie));
                    offset++;
                }
                return response;
            } catch(IOException err) {
                Dialog.show("Error", "Error during connection: " + err, "OK", null);
            }
            return null;
        }
    });
    react.show();
}
 
Example #4
Source File: AudioRecorderComponent.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private Container buildUI() {
    Container out = new Container(new BorderLayout());
    done.remove();
    recordingOff.remove();
    recordingInProgress.remove();
    out.add(BorderLayout.NORTH, BorderLayout.centerEastWest(null, done, LayeredLayout.encloseIn(recordingOff, recordingInProgress)));
    record.remove();
    Container center = new Container(new LayeredLayout());
    center.add(record);
    pause.remove();
    center.add(pause);
    out.add(BorderLayout.CENTER, BorderLayout.centerAbsolute(center));
    
    recordingTime.remove();
    out.add(BorderLayout.SOUTH, FlowLayout.encloseCenter(recordingTime));
    
    return out;
}
 
Example #5
Source File: SpanLabel.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private void wrapText(int alignment) {
    Container parent = text.getParent();
    if(parent == this) {
        parent.removeComponent(text);
        parent = new Container(new FlowLayout(alignment, CENTER));
        parent.getAllStyles().stripMarginAndPadding();
        parent.addComponent(text);
        addComponent(BorderLayout.CENTER, parent);
    } else if (parent.getLayout() instanceof BoxLayout) {
        removeComponent(parent);
        parent.removeComponent(text);
        parent = new Container(new FlowLayout(alignment, CENTER));
        parent.getAllStyles().stripMarginAndPadding();
        parent.addComponent(text);
        addComponent(BorderLayout.CENTER, parent);
    } else {
        ((FlowLayout)parent.getLayout()).setAlign(alignment);
    }
}
 
Example #6
Source File: DateSpinner3D.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Default constructor
 */
public DateSpinner3D() {
    setLayout(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
    add(BorderLayout.CENTER, wrapper);
    Calendar c = Calendar.getInstance();
    currentDay = c.get(Calendar.DAY_OF_MONTH);
    currentMonth = c.get(Calendar.MONTH) + 1;
    currentYear = c.get(Calendar.YEAR);
    
    // If dates should be formatted with month day year in this locale,
    // then the first character of a formatted date should start with a letter
    // otherwise it will start with a number.
    String firstChar = L10NManager.getInstance().formatDateLongStyle(new Date()).substring(0, 1);
    monthDayYear = !firstChar.toLowerCase().equals(firstChar.toUpperCase());
    initSpinner();
}
 
Example #7
Source File: MultiButton.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc }
 * @since 7.0
 */
@Override
public int getTextPosition() {
    String iconPosition = getIconPosition();
    if (BorderLayout.NORTH.equals(iconPosition)) {
        return Component.BOTTOM;
    }
    if (BorderLayout.SOUTH.equals(iconPosition)) {
        return Component.TOP;
    }
    if (BorderLayout.EAST.equals(iconPosition)) {
        return Component.LEFT;
    }
    if (BorderLayout.WEST.equals(iconPosition)) {
        return Component.RIGHT;
    }
    return Component.LEFT;
    
}
 
Example #8
Source File: KitchenSink.java    From codenameone-demos with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method wraps the layout in a way so the shelves are rendered underneath the
 * given component
 */
private Container wrapInShelves(Container c) {
    Container layered = new Container(new LayeredLayout());
    Container sides = new Container(new BorderLayout());
    Label right = new Label(" ");
    right.setUIID("Right");
    sides.addComponent(BorderLayout.EAST, right);
    Label left = new Label(" ");
    left.setUIID("Left");
    sides.addComponent(BorderLayout.WEST, left);
    layered.addComponent(sides);
    
    layered.addComponent(c);
    
    return layered;
}
 
Example #9
Source File: InterFormContainer.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Injects the given "content" as an InterFormContainer inside the component hierarchy
 * rooted at "root"
 * @param selector A selector to identify the component to add the container to.  See {@link ComponentSelector}.
 * @param root The root container serving as a starting point for the selector search.
 * @param content The content to inject.
 * @return The InterFormContainer that was injected, or null if the selector didn't match any containers.
 */
public static InterFormContainer inject(String selector, Container root, Component content) {
    for (Component c : $(selector, root)) {
        if (c instanceof Container) {
            Container slotCnt = (Container)c;
            if (!(slotCnt.getLayout() instanceof BorderLayout)) {
                slotCnt.setLayout(new BorderLayout());
            }
            slotCnt.getStyle().stripMarginAndPadding();
            slotCnt.removeAll();

            InterFormContainer ifc = new InterFormContainer(content);
            slotCnt.add(BorderLayout.CENTER, ifc);
            return ifc;
        }
    }
    return null;
}
 
Example #10
Source File: PhotoShare.java    From codenameone-demos with GNU General Public License v2.0 6 votes vote down vote up
private void showMainForm() {
    final Form photos = new Form("Photos");
    photos.setLayout(new BorderLayout());
    GridLayout gr = new GridLayout(1, 1);
    final Container grid = new Container(gr);
    gr.setAutoFit(true);
    grid.setScrollableY(true);
    grid.addPullToRefresh(new Runnable() {
        public void run() {
            refreshGrid(grid);
        }
    });

    grid.addComponent(new InfiniteProgress());
    photos.addComponent(BorderLayout.CENTER, grid);

    photos.removeAllCommands();
    photos.setBackCommand(null);
    photos.addCommand(createPictureCommand(grid));

    photos.show();
    refreshGrid(grid);
}
 
Example #11
Source File: Toolbar.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Places a component in the south portion (bottom) of the right side menu.
 * Notice this only works with on-top side menu and the permanent side menu.
 * Setting this value to null will remove the existing component. Only one
 * component can be placed in the south but it can be a container that
 * includes many components
 *
 * @param sidemenuSouthComponent the new component to place in the south or
 * null to remove the current component
 */
public void setComponentToRightSideMenuSouth(Component sidemenuSouthComponent) {
    if (this.rightSidemenuSouthComponent != null) {
        rightSidemenuSouthComponent.remove();
    }
    this.rightSidemenuSouthComponent = sidemenuSouthComponent;
    if (this.rightSidemenuSouthComponent != null) {
        if (rightSidemenuDialog != null) {
            rightSidemenuDialog.add(BorderLayout.SOUTH, sidemenuSouthComponent);
        } else {
            if (permanentSideMenu && permanentSideMenuContainer != null) {
                Form parent = getComponentForm();
                parent.removeComponentFromForm(permanentRightSideMenuContainer);
                Container c = BorderLayout.center(permanentRightSideMenuContainer);
                c.add(BorderLayout.SOUTH, sidemenuSouthComponent);
                parent.addComponentToForm(BorderLayout.EAST, c);
            }
        }
    }
}
 
Example #12
Source File: SpanLabel.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc }
 * @since 7.0
 */
@Override
public int getTextPosition() {
    String iconPosition = getIconPosition();
    if (BorderLayout.NORTH.equals(iconPosition)) {
        return Component.BOTTOM;
    }
    if (BorderLayout.SOUTH.equals(iconPosition)) {
        return Component.TOP;
    }
    if (BorderLayout.EAST.equals(iconPosition)) {
        return Component.LEFT;
    }
    if (BorderLayout.WEST.equals(iconPosition)) {
        return Component.RIGHT;
    }
    return Component.LEFT;
    
}
 
Example #13
Source File: StateMachine.java    From codenameone-demos with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void beforeMaps(Form f) {
    Container entriesContainer = findEntries(f);
    ((BorderLayout)entriesContainer.getLayout()).setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_TOTAL_BELLOW);
    MapComponent map = findMapEntry(f);
    entriesContainer.removeComponent(map);
    entriesContainer.addComponent(0, BorderLayout.CENTER, map);
    if(Display.getInstance().isTablet()) {
        Container listATMs = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        listATMs.setHideInPortrait(true);
        addATMs(listATMs, false);
        Container portraitListATMs = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        addATMs(portraitListATMs, false);            
        MasterDetail.bindTabletLandscapeMaster(f, f, listATMs, portraitListATMs, "ATM's", null);
        entriesContainer.removeComponent(findMapOverlay(f));
    } else {
        findAtmMainTitle(f).setText(current.name);
        findAtmMainDistance(f).setText(current.distance);
        findAtmMainZip(f).setText(current.zip);
        findAtmMainText(f).setText(current.location);
        findAtmMainUnit(f).setText(current.metric);
        findAtmMainPaid(f).setText(current.paid);
    }
    updateFormMap(f);
}
 
Example #14
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 #15
Source File: MenuBar.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds the MenuBar on the parent Form
 */
protected void installMenuBar() {
    if (getParent() == null) {
        int type = getCommandBehavior();
        if (type == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT 
                || type == Display.COMMAND_BEHAVIOR_ICS
                || type == Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION) {
            //getTitleAreaContainer().addComponent(BorderLayout.EAST, this);
            return;
        }
        int softkeyCount = Display.getInstance().getImplementation().getSoftkeyCount();
        if (softkeyCount > 1 || type == Display.COMMAND_BEHAVIOR_BUTTON_BAR
                || type == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK) {
            if(Display.getInstance().getProperty("adPaddingBottom", null) == null) {
                parent.addComponentToForm(BorderLayout.SOUTH, this);
            }
        }
    }
}
 
Example #16
Source File: SwipeableContainer.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Simple Constructor
 * 
 * @param bottomLeft the Component below the top, this Component is exposed 
 * when dragging the top to the right
 * @param bottomRight the Component below the top, this Component is exposed 
 * when dragging the top to the Left
 * @param top the component on top.
 */ 
public SwipeableContainer(Component bottomLeft, Component bottomRight, Component top) {
    setLayout(new LayeredLayout());
    bottomLeftWrapper = new Container(new BorderLayout());
    if(bottomLeft != null){
        bottomLeftWrapper.addComponent(BorderLayout.WEST, bottomLeft);
        bottomLeftWrapper.setVisible(false);
    }

    bottomRightWrapper = new Container(new BorderLayout());
    if(bottomRight != null){
        bottomRightWrapper.addComponent(BorderLayout.EAST, bottomRight);
        bottomRightWrapper.setVisible(false);
    }

    topWrapper = new Container(new BorderLayout());
    topWrapper.addComponent(BorderLayout.CENTER, top);
    addComponent(bottomRightWrapper);
    addComponent(bottomLeftWrapper);
    addComponent(topWrapper);

    press = new SwipeListener(SwipeListener.PRESS);
    drag = new SwipeListener(SwipeListener.DRAG);
    release = new SwipeListener(SwipeListener.RELEASE);
}
 
Example #17
Source File: SideMenuBar.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void removeCommand(Command cmd) {
    super.removeCommand(cmd);
    if (parent instanceof Dialog) {
        return;
    }
    if(cmd.getClientProperty("TitleCommand") != null && parent != null) {
        removeCommandComponent(getTitleAreaContainer(), cmd);
    }
    if(rightCommands != null){
        rightCommands.remove(cmd);
    }
    if(leftCommands != null){
        leftCommands.remove(cmd);
    }
    if (getCommandCount() == 0) {
        if (getTitleComponent() != null) {
            getTitleComponent().getParent().removeAll();
        }
        getTitleAreaContainer().removeAll();
        getTitleAreaContainer().addComponent(BorderLayout.CENTER, getTitleComponent());
    }        
    installRightCommands();
    installLeftCommands();
}
 
Example #18
Source File: AbstractDemoChart.java    From codenameone-demos with GNU General Public License v2.0 6 votes vote down vote up
protected Form wrap(String title, Component c){
    c.getStyle().setBgColor(0xff0000);
    Form f = new Form(title);
    f.setLayout(new BorderLayout());
    if (isDrawOnMutableImage()) {
        int dispW = Display.getInstance().getDisplayWidth();
        int dispH = Display.getInstance().getDisplayHeight();
        Image img = Image.createImage((int)(dispW * 0.8), (int)(dispH * 0.8), 0x0);
        Graphics g = img.getGraphics();
        c.setWidth((int)(dispW * 0.8));
        c.setHeight((int)(dispH * 0.8));
        c.paint(g);
        f.addComponent(BorderLayout.CENTER, new Label(img));
    } else {
      f.addComponent(BorderLayout.CENTER, c);
    }
    
    return f;
}
 
Example #19
Source File: Container.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the layout manager responsible for arranging this container
 * 
 * @param layout the specified layout manager
 */
public void setLayout(Layout layout) {
    if(layout.isConstraintTracking()) {
        for(int iter = 0 ; iter < getComponentCount() ; iter++) {
            Component c = getComponentAt(iter);
            Object cons = this.layout.getComponentConstraint(c);
            if(cons != null) {
                layout.addLayoutComponent(cons, c, this);
            }
        }
    }
    this.layout = layout;
    if(layout instanceof BorderLayout && isScrollable()) {
        setScrollable(false);
    }
}
 
Example #20
Source File: TextAreaSample.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", new BorderLayout());
    TextArea ta = new TextArea();
    
    hi.add(BorderLayout.CENTER, ta);
    hi.show();
    callSerially(()->ta.setText("Some Text"));
}
 
Example #21
Source File: Accordion.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public AccordionContent(Component header, final Component body) {
    setUIID(uiidBackGroundItem);
    setLayout(new BorderLayout());
    this.body = body;
    this.header = header;
    header.setSelectedStyle(header.getUnselectedStyle());
    header.setPressedStyle(header.getUnselectedStyle());
    String t = (String)body.getClientProperty("cn1$setHeaderUIID");
    if(t != null) {
        topUiid = t;
    }

    top = new Container(new BorderLayout(), topUiid);
    top.add(BorderLayout.CENTER, header);
    arrow.setUIID(uiidOpenCloseIcon);
    arrow.setIcon(closeIcon);
    arrow.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            
            //toggle the current
            openClose(!isClosed());
            if(autoClose){
                for (int i = 0; i < Accordion.this.getComponentCount(); i++) {
                    AccordionContent c = (AccordionContent)Accordion.this.getComponentAt(i);
                    if(c != AccordionContent.this && !c.isClosed()){
                        c.openClose(true);
                    }
                }
            }
            Accordion.this.animateLayout(250);
            fireEvent(evt);
        }
    });
    top.add(BorderLayout.EAST, arrow);
    top.setLeadComponent(arrow);
    add(BorderLayout.NORTH, top);
    body.setHidden(true);
    add(BorderLayout.CENTER, body);
}
 
Example #22
Source File: InputComponent.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
void addEditorAction() {
    if(action != null) {
        add(BorderLayout.CENTER, LayeredLayout.encloseIn(
            getEditor(),
            FlowLayout.encloseRightMiddle(action)
        ));
    } else {
        add(BorderLayout.CENTER, getEditor());
    }
}
 
Example #23
Source File: VideoPlayerSample.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("Video Player", new BorderLayout());
    hi.add(BorderLayout.CENTER, createDemo(hi));
    hi.show();
}
 
Example #24
Source File: SocketSample.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
ClientForm() {
    super("Client Form", new BorderLayout());
    connect.setEnabled(true);
    disconnect.setEnabled(false);
    send.setEnabled(false);
    
    
    TextField message = new TextField();
    message.setHint("Message to server");
    
    TextField timeout = new TextField("0");
    timeout.setHint("Timeout");
    
    host.setHint("Hostname");
    
    Container north = new Container(BoxLayout.y());
    north.add(BorderLayout.centerEastWest(host, BoxLayout.encloseX(connect, disconnect, new Label("Timeout:"),timeout), null));
    north.add(BorderLayout.centerEastWest(message, send, null));
    add(NORTH, north);
    add(CENTER, response);
    
    connect.addActionListener(evt->{
        connect(Integer.parseInt(timeout.getText()));
    });
    
    send.addActionListener(evt->{
        send(message.getText());
    });
    
    disconnect.addActionListener(evt-> {
        disconnect();
    });
    
}
 
Example #25
Source File: MenuBar.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the MenuBar from the parent Form
 */
protected void unInstallMenuBar() {
    parent.removeComponentFromForm(this);
    Container t = getTitleAreaContainer();
    BorderLayout titleLayout = (BorderLayout) t.getLayout();
    titleLayout.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_SCALE);
    Component l = getTitleComponent();
    t.removeAll();
    if (l.getParent() != null) {
        l.getParent().removeComponent(l);
    }
    t.addComponent(BorderLayout.CENTER, l);
    initTitleBarStatus();
}
 
Example #26
Source File: TestIOSWebView3062.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
WebForm() {
    super("WebView", new BorderLayout());
    final BrowserComponent cmp = new BrowserComponent();
    
    cmp.addWebEventListener(BrowserComponent.onLoad, evt->{
       cmp.addJSCallback("window.cb = json => {callback.onSuccess(json);};", json-> {
            new ButtonForm().show();
        });
    });
    String html = "<!doctype html><html><body><button onclick='window.cb(); return false;'>Press Me</button></body></html>";
    cmp.setPage(html, null);
    add(CENTER, cmp);
}
 
Example #27
Source File: SpanLabelTests2980.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
private void testBorderLayout() {
    System.out.println("Testing SpanLabel preferred size in BorderLayout.  https://github.com/codenameone/CodenameOne/issues/3000");
    //Button showPopUp = new Button("Show PopUp in Border Layout");
    Form f = new Form(BoxLayout.y());
    f.setName("testBorderLayout");
    //f.add(showPopUp);
    SpanLabel messageSpanLabel = new SpanLabel("Tap the following button to open the gallery. You should be able to select multiple images and videos. Tap the following button to open the gallery. You should be able to select multiple images and videos.");
    //showPopUp.addActionListener((e) -> {
    Runnable showPopup = () -> {
        
        messageSpanLabel.setName("messageSpanLabel");
        Container centerContainerOuter = new Container(new BorderLayout(CENTER_BEHAVIOR_CENTER));
        centerContainerOuter.add(CENTER, messageSpanLabel);

        Container layeredPane = getCurrentForm().getLayeredPane();
        layeredPane.setLayout(new LayeredLayout());        
        layeredPane.add(centerContainerOuter);
        layeredPane.setVisible(true);

        getCurrentForm().revalidate();     
    };
    //showPopUp.setName("showBorderLayout");
    f.show();
    waitForFormName("testBorderLayout");
    //clickButtonByName("showBorderLayout");
    showPopup.run();
    waitFor(500); // give time for click to take effect
    SpanLabel spanLabel = messageSpanLabel; //(SpanLabel)findByName("messageSpanLabel");
    Label l = new Label("Tap the following");

    assertTrue(spanLabel.getHeight() > l.getPreferredH() * 2, "Span Label height is too small.  Should be at least a few lines.");
    System.out.println("Finished SpanLabel BorderLayout test");

}
 
Example #28
Source File: Toolbar.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Empty Constructor
 */
public Toolbar() {
    setLayout(new BorderLayout());
    if (UIManager.getInstance().isThemeConstant("landscapeTitleUiidBool", false)) {
        setUIID("Toolbar", "ToolbarLandscape");
    } else {
        setUIID("Toolbar");
    }
    sideMenu = new ToolbarSideMenu();
    if (centeredDefault
            && UIManager.getInstance().getComponentStyle("Title").getAlignment() == CENTER) {
        setTitleCentered(true);
    }
}
 
Example #29
Source File: FillShapeTest.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start() {
    Form f = new Form("Test Fill Shape");
    f.setLayout(BorderLayout.center());
    ButtonGroup bg = new ButtonGroup();
    drawStringBtn = RadioButton.createToggle("String", bg);
    drawPathBtn = RadioButton.createToggle("Path", bg);
    f.add(BorderLayout.CENTER, new DrawingCanvas());
    f.add(BorderLayout.NORTH, GridLayout.encloseIn(drawStringBtn, drawPathBtn));
    
    f.show();
}
 
Example #30
Source File: RadioButtonLeadComponentTest3105.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("Lead component breaks ComponentGroup", BoxLayout.y());

    ButtonGroup group = new ButtonGroup();
    ComponentGroup cgroup = new ComponentGroup();
    Label editFieldLabel = new Label("");
    Container visibleField = BorderLayout.centerCenterEastWest(cgroup, editFieldLabel, null);
    RadioButton r1 = new RadioButton("R1");
    group.add(r1);
    cgroup.add(r1);
    RadioButton r2 = new RadioButton("R2");
    group.add(r2);
    cgroup.add(r2);
    hi.add(visibleField);

    ButtonGroup group2 = new ButtonGroup();
    ComponentGroup cgroup2 = new ComponentGroup();
    Label editFieldLabel2 = new Label("EDIT2");
    Container visibleField2 = BorderLayout.centerCenterEastWest(cgroup2, editFieldLabel2, null);
    RadioButton r3 = new RadioButton("R3");
    group2.add(r3);
    cgroup2.add(r3);
    RadioButton r4 = new RadioButton("R4");
    group2.add(r4);
    cgroup2.add(r4);
    hi.add(visibleField2);

    //What causes the problem:
    cgroup2.setBlockLead(true);
    visibleField2.setLeadComponent(cgroup2); //making the ComponentGroup lead makes it impossible to select the radio buttons

    hi.show();
}