Java Code Examples for com.codename1.ui.Form#setScrollable()

The following examples show how to use com.codename1.ui.Form#setScrollable() . 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: Log.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Places a form with the log as a TextArea on the screen, this method can
 * be attached to appear at a given time or using a fixed global key. Using
 * this method might cause a problem with further log output
 * @deprecated this method is an outdated method that's no longer supported
 */
public static void showLog() {
    try {
        String text = getLogContent();
        TextArea area = new TextArea(text, 5, 20);
        Form f = new Form("Log");
        f.setScrollable(false);
        final Form current = Display.getInstance().getCurrent();
        Command back = new Command("Back") {
            public void actionPerformed(ActionEvent ev) {
                current.show();
            }
        };
        f.addCommand(back);
        f.setBackCommand(back);
        f.setLayout(new BorderLayout());
        f.addComponent(BorderLayout.CENTER, area);
        f.show();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 2
Source File: MapsDemo.java    From codenameone-demos with GNU General Public License v2.0 5 votes vote down vote up
private void showMeOnMap() {
    Form map = new Form("Map");
    map.setLayout(new BorderLayout());
    map.setScrollable(false);
    final MapComponent mc = new MapComponent();

    putMeOnMap(mc);
    mc.zoomToLayers();

    map.addComponent(BorderLayout.CENTER, mc);
    map.getToolbar().addCommandToLeftBar(new MapsDemo.BackCommand());
    map.setBackCommand(new MapsDemo.BackCommand());
    map.show();

}
 
Example 3
Source File: SwitchScrollWheelingIssue.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 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();
}
 
Example 4
Source File: LeadComponentDropListenerSample.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 GridLayout(1, 2));
    hi.setScrollable(false);
    Container draggable = new Container(new FlowLayout());
    Label lead = new Label("Draggable");
    draggable.add(lead);
    draggable.setLeadComponent(lead);
    
    draggable.getStyle().setBorder(Border.createLineBorder(1, 0xff0000));
    draggable.setDraggable(true);
    lead.addDropListener(evt->{
        
        System.out.println("Dropped");
    });
    
    Container dropTarget = new Container(new FlowLayout())  {
        @Override
        public void paint(Graphics g) {
            super.paint(g);
            g.setColor(0x0);
            g.setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
            g.drawString("Drop Target", 0, 0);
            
        }
        
    };
    dropTarget.getStyle().setBorder(Border.createLineBorder(1, 0x00ff00));
    dropTarget.setDropTarget(true);
    
    dropTarget.add(new Label("DropTarget"));
    hi.addAll(draggable, dropTarget);
    hi.show();
}
 
Example 5
Source File: CameraKitPickerTest7.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void showAnotherForm(){
    Form form = new Form(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE));
    form.setScrollable(false);
    Container container = new Container(BoxLayout.y());
    container.add(new Label("Test", "heading5"));
    container.add(new Label("", "newLine"));
    container.add(new Label("", "newLine"));

    final Picker fromDate = new Picker();
    fromDate.setType(Display.PICKER_TYPE_DATE);
    container.add(new Label("From Date", "heading7"));
    container.add(fromDate);
    container.add(new Label("", "newLine"));

    final Picker toDate = new Picker();
    toDate.setType(Display.PICKER_TYPE_DATE);
    container.add(new Label("To Date", "heading7"));
    container.add(toDate);

    Button nextBtn = new Button("Proceed");
    nextBtn.setUIID("loginBtn");
    nextBtn.addActionListener((ev) -> {
        DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
        String fromDateStr = dateFormat.format(fromDate.getDate());
        String toDateStr = dateFormat.format(toDate.getDate());
        
    });
    container.add(new Label("", "newLine"));
    container.add(new Label("", "newLine"));
    container.add(nextBtn);
    form.add(BorderLayout.CENTER, container);
    
    form.show();
}
 
Example 6
Source File: Poker.java    From codenameone-demos with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The splash screen is relatively bare bones. Its important to have a splash screen for iOS 
 * since the build process generates a screenshot of this screen to speed up perceived performance
 */
public void showSplashScreen() {
    final Form splash = new Form();
    
    // a border layout places components in the center and the 4 sides.
    // by default it scales the center component so here we configure
    // it to place the component in the actual center
    BorderLayout border = new BorderLayout();
    border.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
    splash.setLayout(border);
    
    // by default the form's content pane is scrollable on the Y axis
    // we need to disable it here
    splash.setScrollable(false);
    Label title = new Label("Poker Ace");
    
    // The UIID is used to determine the appearance of the component in the theme
    title.setUIID("SplashTitle");
    Label subtitle = new Label("By Codename One");
    subtitle.setUIID("SplashSubTitle");
    
    splash.addComponent(BorderLayout.NORTH, title);
    splash.addComponent(BorderLayout.SOUTH, subtitle);
    Label as = new Label(cards.getImage("as.png"));
    Label ah = new Label(cards.getImage("ah.png"));
    Label ac = new Label(cards.getImage("ac.png"));
    Label ad = new Label(cards.getImage("ad.png"));

    // a layered layout places components one on top of the other in the same dimension, it is
    // useful for transparency but in this case we are using it for an animation
    final Container center = new Container(new LayeredLayout());
    center.addComponent(as);
    center.addComponent(ah);
    center.addComponent(ac);
    center.addComponent(ad);
    
    splash.addComponent(BorderLayout.CENTER, center);
            
    splash.show();
    splash.setTransitionOutAnimator(CommonTransitions.createCover(CommonTransitions.SLIDE_VERTICAL, true, 800));

    // postpone the animation to the next cycle of the EDT to allow the UI to render fully once
    Display.getInstance().callSerially(new Runnable() {
        public void run() {
            // We replace the layout so the cards will be laid out in a line and animate the hierarchy
            // over 2 seconds, this effectively creates the effect of cards spreading out
            center.setLayout(new BoxLayout(BoxLayout.X_AXIS));
            center.setShouldCalcPreferredSize(true);
            splash.getContentPane().animateHierarchy(2000);

            // after showing the animation we wait for 2.5 seconds and then show the game with a nice
            // transition, notice that we use UI timer which is invoked on the Codename One EDT thread!
            new UITimer(new Runnable() {
                public void run() {
                    showGameUI();
                }
            }).schedule(2500, false, splash);
        }
    });
}
 
Example 7
Source File: KitchenSink.java    From codenameone-demos with GNU General Public License v2.0 4 votes vote down vote up
private void showSplashAnimation() {
    Form splash = new Form();
    splash.setUIID("Splash");
    splash.getContentPane().setUIID("Container");
    splash.getTitleArea().setUIID("Container");
    BorderLayout border = new BorderLayout();
    border.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
    splash.setLayout(border);
    splash.setScrollable(false);
    Label title = new Label("Kitchen Sink Demo");
    title.setUIID("SplashTitle");
    Label subtitle = new Label("By Codename One");
    subtitle.setUIID("SplashSubTitle");
    splash.addComponent(BorderLayout.NORTH, title);
    splash.addComponent(BorderLayout.SOUTH, subtitle);
    Label beaker = new Label(res.getImage("beaker.png"));
    final Label beakerLogo = new Label(res.getImage("beaker_logo.png"));
    beakerLogo.setVisible(false);
    Container layeredLayout = new Container(new LayeredLayout());
    splash.addComponent(BorderLayout.CENTER, layeredLayout);
    layeredLayout.addComponent(beaker);
    final Container logoParent = new Container(new BorderLayout());
    layeredLayout.addComponent(logoParent);
    logoParent.addComponent(BorderLayout.CENTER, beakerLogo);
    splash.revalidate();
    
    Display.getInstance().callSerially(new Runnable() {
        public void run() {
            beakerLogo.setVisible(true);
            beakerLogo.setX(0);
            beakerLogo.setY(0);
            beakerLogo.setWidth(3);
            beakerLogo.setHeight(3);
            logoParent.setShouldCalcPreferredSize(true);
            logoParent.animateLayoutFade(2000, 0);
        }
    });
    
    splash.show();
    splash.setTransitionOutAnimator(CommonTransitions.createFastSlide(CommonTransitions.SLIDE_VERTICAL, true, 300));
    new UITimer(new Runnable() {
        public void run() {
            showMainUI();
        }
    }).schedule(2500, false, splash);
}
 
Example 8
Source File: Oauth2.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method shows an authentication for login form
 *
 * @param al a listener that will receive at its source either a token for
 * the service or an exception in case of a failure
 * @return a component that should be displayed to the user in order to
 * perform the authentication
 */
public void showAuthentication(final ActionListener al) {
    
    if (useBrowserWindow) {
        final BrowserWindow win = new BrowserWindow(buildURL());
        win.setTitle("Login");
        win.addLoadListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                String url = (String)evt.getSource();
                if (url.startsWith(redirectURI)) {
                    win.close();
                    handleURL((String)evt.getSource(), null, al, null, null, null);
                }    
            }
        });

        win.show(); 
        return;
        
    }
    
    final Form old = Display.getInstance().getCurrent();
    InfiniteProgress inf = new InfiniteProgress();
    final Dialog progress = inf.showInifiniteBlocking();
    Form authenticationForm = new Form("Login");
    authenticationForm.setScrollable(false);
    if (old != null) {
        Command cancel = new Command("Cancel") {
            public void actionPerformed(ActionEvent ev) {
                if (Display.getInstance().getCurrent() == progress) {
                    progress.dispose();
                }
                old.showBack();
            }
        };
        if (authenticationForm.getToolbar() != null){
            authenticationForm.getToolbar().addCommandToLeftBar(cancel);
        } else {
            authenticationForm.addCommand(cancel);
        }
        authenticationForm.setBackCommand(cancel);
    }
    authenticationForm.setLayout(new BorderLayout());
    authenticationForm.addComponent(BorderLayout.CENTER, createLoginComponent(al, authenticationForm, old, progress));
}