Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.codename1.tests.textediting;
- import com.codename1.ui.Command;
- import com.codename1.ui.Display;
- import com.codename1.ui.Form;
- import com.codename1.ui.Label;
- import com.codename1.ui.TextField;
- import com.codename1.ui.Toolbar;
- import com.codename1.ui.events.ActionEvent;
- import com.codename1.ui.layouts.BorderLayout;
- import com.codename1.ui.layouts.BoxLayout;
- import com.codename1.ui.plaf.UIManager;
- import com.codename1.ui.util.Resources;
- import java.io.IOException;
- public class IOSTextEditing {
- private Form current;
- private Resources theme;
- public void init(Object context) {
- theme = UIManager.initFirstTheme("/theme");
- // Pro users - uncomment this code to get crash reports sent to you automatically
- /*Display.getInstance().addEdtErrorHandler(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- evt.consume();
- Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
- Log.p("OS " + Display.getInstance().getPlatformName());
- Log.p("Error " + evt.getSource());
- Log.p("Current Form " + Display.getInstance().getCurrent().getName());
- Log.e((Throwable)evt.getSource());
- Log.sendLog();
- }
- });*/
- }
- private void createToolbar(Form f) {
- Toolbar tb = new Toolbar();
- f.setToolBar(tb);
- tb.addCommandToSideMenu(new Command("Legacy Test") {
- @Override
- public void actionPerformed(ActionEvent evt) {
- showLegacyTestForm();
- }
- });
- tb.addCommandToSideMenu(new Command("Async Test") {
- @Override
- public void actionPerformed(ActionEvent evt) {
- showAsyncTestForm();
- }
- });
- tb.addCommandToSideMenu(new Command("Bottom Padding") {
- @Override
- public void actionPerformed(ActionEvent evt) {
- showBottomPaddingTestForm();
- }
- });
- }
- public void start() {
- if(current != null){
- current.show();
- return;
- }
- Form hi = new Form("Hi World");
- createToolbar(hi);
- hi.addComponent(new Label("Hi World"));
- hi.show();
- }
- private void showLegacyTestForm() {
- Form hi = new Form("Legacy Test");
- createToolbar(hi);
- hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
- for (int i=0; i<30; i++) {
- hi.addComponent(new TextField("Field "+i));
- }
- hi.setScrollableY(false);
- hi.show();
- }
- private void showBottomPaddingTestForm() {
- Form hi = new Form("Bottom Padding");
- createToolbar(hi);
- hi.setFormBottomPaddingEditingMode(true);
- hi.setLayout(new BorderLayout());
- hi.addComponent(BorderLayout.SOUTH, new TextField("Some text"));
- hi.show();
- }
- private void showAsyncTestForm() {
- Form hi = new Form("Async Test");
- createToolbar(hi);
- hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
- for (int i=0; i<30; i++) {
- hi.addComponent(new TextField("Field "+i));
- }
- hi.setScrollableY(true);
- hi.show();
- }
- public void stop() {
- current = Display.getInstance().getCurrent();
- }
- public void destroy() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement