当前位置: 首页>>代码示例>>Java>>正文


Java TextField类代码示例

本文整理汇总了Java中com.codename1.ui.TextField的典型用法代码示例。如果您正苦于以下问题:Java TextField类的具体用法?Java TextField怎么用?Java TextField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextField类属于com.codename1.ui包,在下文中一共展示了TextField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getComponentRegistry

import com.codename1.ui.TextField; //导入依赖的package包/类
static Hashtable getComponentRegistry() {
    if(componentRegistry == null) {
        componentRegistry = new Hashtable();
        componentRegistry.put("Button", Button.class);
        componentRegistry.put("Calendar", com.codename1.ui.Calendar.class);
        componentRegistry.put("CheckBox", CheckBox.class);
        componentRegistry.put("ComboBox", ComboBox.class);
        componentRegistry.put("Container", Container.class);
        componentRegistry.put("Dialog", Dialog.class);
        componentRegistry.put("Form", Form.class);
        componentRegistry.put("Label", Label.class);
        componentRegistry.put("List", List.class);
        componentRegistry.put("RadioButton", RadioButton.class);
        componentRegistry.put("Slider", Slider.class);
        componentRegistry.put("Tabs", Tabs.class);
        componentRegistry.put("TextArea", TextArea.class);
        componentRegistry.put("TextField", TextField.class);
        componentRegistry.put("EmbeddedContainer", EmbeddedContainer.class);
    }
    return componentRegistry;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:UIBuilder.java

示例2: addPlaylistAdd

import com.codename1.ui.TextField; //导入依赖的package包/类
private void addPlaylistAdd(final Form f)
{
    //TODO: Enabled this again when Shai has fixed deleting titlecommands
    //if(titleCommand != null)
    //   f.removeCommand(titleCommand);
    
    ui.removeTitleCommand(f);
    
    Image icon = StateMachine.getResourceFile().getImage("playlist_plus_static.png");
    icon.lock();
    Image iconPressed = StateMachine.getResourceFile().getImage("playlist_plus_active.png");
    iconPressed.lock();
    titleCommand = new Command(null, icon){
        @Override
        public void actionPerformed(ActionEvent evt) {
            addPlaylistCancel(f);
            ui.resetComponentHeight(ui.findCtnAddPlaylistForm(f));
            ui.findTfdAddPlaylistFormTitle(f).requestFocus();
            Display.getInstance().editString(ui.findTfdAddPlaylistFormTitle(f), 200, TextField.ANY, "");
        }
    };
    titleCommand.setPressedIcon(iconPressed);
    titleCommand.putClientProperty("TitleCommand", Boolean.TRUE);
    f.addCommand(titleCommand);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:26,代码来源:PlaylistOverviewView.java

示例3: createDemo

import com.codename1.ui.TextField; //导入依赖的package包/类
public Container createDemo() {
    Container input = new Container(new BoxLayout(BoxLayout.Y_AXIS));
    input.addComponent(new Label("Text Field"));
    input.addComponent(new TextField("Hi World"));
    input.addComponent(new Label("Text Field With Hint"));
    TextField hint = new TextField();
    hint.setHint("Hint");
    input.addComponent(hint);
    input.addComponent(new Label("Multi-Line Text Field"));
    TextField multi = new TextField();
    multi.setSingleLineTextArea(false);
    multi.setRows(4);
    multi.setColumns(20);
    input.addComponent(multi);
    return input;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:17,代码来源:Input.java

示例4: start

import com.codename1.ui.TextField; //导入依赖的package包/类
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Signature Component");
    hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    hi.add("Enter Your Name:");
    hi.add(new TextField());
    hi.add("Signature:");
    SignatureComponent sig = new SignatureComponent();
    sig.addActionListener((evt)-> {
        System.out.println("The signature was changed");
        Image img = sig.getSignatureImage();
        // Now we can do whatever we want with the image of this signature.
    });
    hi.addComponent(sig);
    hi.show();
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:20,代码来源:SignatureComponentDemo.java

示例5: performEditorAction

import com.codename1.ui.TextField; //导入依赖的package包/类
@Override
public boolean performEditorAction(int actionCode) {
    if (Display.isInitialized() && Display.getInstance().getCurrent() != null) {
        Component txtCmp = Display.getInstance().getCurrent().getFocused();
        if (txtCmp != null && txtCmp instanceof TextField) {
            TextField t = (TextField) txtCmp;
            if (actionCode == EditorInfo.IME_ACTION_DONE) {
                Display.getInstance().setShowVirtualKeyboard(false);
            } else if (actionCode == EditorInfo.IME_ACTION_NEXT) {
                Display.getInstance().setShowVirtualKeyboard(false);
                txtCmp.getNextFocusDown().requestFocus();
            }
        }
    }

    return super.performEditorAction(actionCode);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:18,代码来源:CodenameOneInputConnection.java

示例6: setComposingText

import com.codename1.ui.TextField; //导入依赖的package包/类
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
    if (Display.isInitialized() && Display.getInstance().getCurrent() != null) {
        Component txtCmp = Display.getInstance().getCurrent().getFocused();
        if (txtCmp != null && txtCmp instanceof TextField) {
            TextField t = (TextField) txtCmp;
            String textFieldText = t.getText();
            StringBuilder sb = new StringBuilder(textFieldText);
            sb.replace(sb.length() - composingText.length(), sb.length(), text.toString());
            int cursorPosition = t.getCursorPosition();
            composingText = text.toString();
            t.setText(sb.toString());
            t.setCursorPosition(cursorPosition + text.length());

            updateExtractedText();
            return true;
        }
    }
    return false;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:CodenameOneInputConnection.java

示例7: getTextBeforeCursor

import com.codename1.ui.TextField; //导入依赖的package包/类
@Override
public CharSequence getTextBeforeCursor(int length, int flags) {
    if (Display.isInitialized() && Display.getInstance().getCurrent() != null) {
        Component txtCmp = Display.getInstance().getCurrent().getFocused();
        if (txtCmp != null && txtCmp instanceof TextField) {
            String txt = ((TextField) txtCmp).getText();
            int position = ((TextField) txtCmp).getCursorPosition();
            int start;
            if (position > 0) {
                start = txt.subSequence(0, position).toString().lastIndexOf(" ");
                if (start > 0) {
                    return txt.subSequence(start, position);
                } else {
                    return txt.subSequence(0, position);
                }
            }
        }
    }
    return "";
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:CodenameOneInputConnection.java

示例8: TextAreaData

import com.codename1.ui.TextField; //导入依赖的package包/类
TextAreaData(TextArea ta) {

            absoluteX = ta.getAbsoluteX();
            absoluteY = ta.getAbsoluteY();
            scrollX = ta.getScrollX();
            scrollY = ta.getScrollY();
            Style s = ta.getStyle();
            paddingTop = s.getPaddingTop();
            paddingLeft = s.getPaddingLeft(ta.isRTL());
            paddingRight = s.getPaddingRight(ta.isRTL());
            paddingBottom = s.getPaddingBottom();
            isTextField = (ta instanceof TextField);
            verticalAlignment = ta.getVerticalAlignment();
            height = ta.getHeight();
            width = ta.getWidth();
            fontHeight = s.getFont().getHeight();
            textArea = ta;
            isRTL = ta.isRTL();
            nextDown = textArea.getNextFocusDown() != null ? textArea.getNextFocusDown() : textArea.getComponentForm().findNextFocusVertical(true);
            isSingleLineTextArea = textArea.isSingleLineTextArea();
            hint = ta.getHint();
            nativeHintBool = textArea.getUIManager().isThemeConstant("nativeHintBool", false);
            nativeFont = s.getFont().getNativeFont();
            fgColor = s.getFgColor();
            maxSize = ta.getMaxSize();
        }
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:InPlaceEditView.java

示例9: install

import com.codename1.ui.TextField; //导入依赖的package包/类
/**
 * Installs a search field on a list making sure the filter method is invoked properly
 */
public static void install(final TextField search, final List l) {
    search.addDataChangedListener(new DataChangedListener() {
        public void dataChanged(int type, int index) {
            FilterProxyListModel f;
            if(l.getModel() instanceof FilterProxyListModel) {
                f = (FilterProxyListModel)l.getModel();
            } else {
                if(search.getText().length() == 0) {
                    return;
                }
                f = new FilterProxyListModel(l.getModel());
                l.setModel(f);
            }
            if(search.getText().length() == 0) {
                l.setModel(f.getUnderlying());
            } else {
                f.filter(search.getText());
            }
        }
    });        
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:25,代码来源:FilterProxyListModel.java

示例10: excludeInputMode

import com.codename1.ui.TextField; //导入依赖的package包/类
/**
 * Excludes the given input mode from the given TextField
 * 
 * @param tf The TextField to work on
 * @param modeToExclude The mode to exclude
 */
private void excludeInputMode(TextField tf,String modeToExclude) {
    String[] curModes=tf.getInputModeOrder();
    String[] newModes=new String[curModes.length-1];
    int j=0;
    for(int i=0;i<curModes.length;i++) {
        if (!curModes[i].equals(modeToExclude)) {
            if (j<newModes.length) {
                newModes[j]=curModes[i];
                j++;
            } else {
                return; //Mode was not there in the first place
            }
        }
    }
    tf.setInputModeOrder(newModes);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:23,代码来源:HTMLInputFormat.java

示例11: verifyChar

import com.codename1.ui.TextField; //导入依赖的package包/类
/**
 * Verifies the given character. THis method is used by verifyString on each char
 * 
 * @param c The char to verify
 * @param constraint The constraint to verify againts
 * @return true if the char conforms to the given constraint, false otherwise
 */
private boolean verifyChar(char c,int constraint) {
    if (((constraint & FormatConstraint.TYPE_ANY)!=0) ||
       (((constraint & FormatConstraint.TYPE_NUMERIC)!=0) && (c>='0') && (c<='9')) ||
       (((constraint & FormatConstraint.TYPE_UPPERCASE)!=0) && (c>='A') && (c<='Z')) ||
       (((constraint & FormatConstraint.TYPE_LOWERCASE)!=0) && (c>='a') && (c<='z'))) {
        return true;
    }

    if ((constraint & FormatConstraint.TYPE_SYMBOL)!=0) {
        char[] symbols=TextField.getSymbolTable();
        for(int i=0;i<symbols.length;i++) {
            if (symbols[i]==c) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:HTMLInputFormat.java

示例12: actionPerformed

import com.codename1.ui.TextField; //导入依赖的package包/类
/**
 * {{@inheritDoc}}
 */
public void actionPerformed(ActionEvent evt) {
    if (getComponentForm().getFocused() instanceof TextField) {
        return;
    }
    int keyCode=evt.getKeyEvent();
    Object obj = accessKeys.get(new Integer(keyCode));
    if (obj!=null) {
        if (obj instanceof HTMLLink) {
            HTMLLink htmlLink = (HTMLLink)obj;
            htmlLink.actionPerformed(null);
        } else if (obj instanceof ForLabel) {
            ((ForLabel)obj).triggerAction();
        } else if (obj instanceof Component) {
            selectComponent((Component)obj);
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:HTMLComponent.java

示例13: deregisterAll

import com.codename1.ui.TextField; //导入依赖的package包/类
/**
 * Deregisters all the listeners, happens before a new page is loaded
 */
void deregisterAll() {
    for(Enumeration e=comps.keys();e.hasMoreElements();) {
        Component cmp = (Component)e.nextElement();
        cmp.removeFocusListener(this);
        if (cmp instanceof Button) { // catches Button, CheckBox, RadioButton
            ((Button)cmp).removeActionListener(this);
        } else if (cmp instanceof List) { // catches ComboBox
            ((List)cmp).removeSelectionListener((SelectionListener)listeners.get(cmp));
        } else if (cmp instanceof TextArea) {
            ((TextArea)cmp).removeActionListener(this);
            if (cmp instanceof TextField) {
                ((TextField)cmp).removeDataChangeListener((DataChangedListener)listeners.get(cmp));
            }
        }
    }
    comps=new Hashtable();
    listeners=new Hashtable();
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:HTMLEventsListener.java

示例14: endEditing

import com.codename1.ui.TextField; //导入依赖的package包/类
/**
 * Finish the in-place editing of the given text area, release the edit lock, and allow the synchronous call
 * to 'edit' to return.
 */
private synchronized void endEditing(int reason, boolean forceVKBOpen) {

    if (mEditText == null) {
        return;
    }
    setVisibility(GONE);
    mLastEndEditReason = reason;

    // If the IME action is set to NEXT, do not hide the virtual keyboard
    boolean isNextActionFlagSet = (mEditText.getImeOptions() == EditorInfo.IME_ACTION_NEXT);
    boolean leaveKeyboardShowing = (reason == REASON_IME_ACTION) && isNextActionFlagSet || forceVKBOpen;
    if (!leaveKeyboardShowing) {
        showVirtualKeyboard(false);
    }
    if(reason == REASON_IME_ACTION &&
            mEditText.getImeOptions() == EditorInfo.IME_ACTION_DONE && 
            mEditText.mTextArea instanceof TextField ){
        ((TextField)mEditText.mTextArea).fireDoneEvent();
    }
    
    mIsEditing = false;
    mLastEditText = mEditText;
    removeView(mEditText);
    mEditText = null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:30,代码来源:InPlaceEditView.java

示例15: editingUpdate

import com.codename1.ui.TextField; //导入依赖的package包/类
public static void editingUpdate(String s, int cursorPositon, boolean finished) {
    if(instance.currentEditing != null) {
        if(finished) {
            editNext = cursorPositon == -2;
            synchronized(EDITING_LOCK) {
                instance.currentEditing.setText(s);
                Display.getInstance().onEditingComplete(instance.currentEditing, s);
                if(editNext && instance.currentEditing != null && instance.currentEditing instanceof TextField) {
                    ((TextField)instance.currentEditing).fireDoneEvent();
                }
                instance.currentEditing = null;
                EDITING_LOCK.notify();
            }
        } else {
            instance.currentEditing.setText(s);
        }
        if(instance.currentEditing instanceof TextField && cursorPositon > -1) {
            ((TextField)instance.currentEditing).setCursorPosition(cursorPositon);
        }
    } else {
        System.out.println("Editing null component!!" + s);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:IOSImplementation.java


注:本文中的com.codename1.ui.TextField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。