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


Java InputMethod类代码示例

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


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

示例1: getChars

import org.microemu.device.InputMethod; //导入依赖的package包/类
public char[] getChars(int inputMode)
{
    char[] result = null;
    switch (inputMode) {
        case InputMethod.INPUT_123 : 
            result = (char[]) inputToChars.get("123");
            break;
        case InputMethod.INPUT_ABC_LOWER : 
            result = (char[]) inputToChars.get("abc");
            break;
        case InputMethod.INPUT_ABC_UPPER : 
            result = (char[]) inputToChars.get("ABC");
            break;
    }
    if (result == null) {
        result = (char[]) inputToChars.get("common");
    }
    if (result == null) {
        result = new char[0];
    }
    
    return result;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:24,代码来源:SwtButton.java

示例2: getChars

import org.microemu.device.InputMethod; //导入依赖的package包/类
public char[] getChars(int inputMode) {
	char[] result = null;
	switch (inputMode) {
	case InputMethod.INPUT_123:
		result = (char[]) inputToChars.get("123");
		break;
	case InputMethod.INPUT_ABC_LOWER:
		result = (char[]) inputToChars.get("abc");
		break;
	case InputMethod.INPUT_ABC_UPPER:
		result = (char[]) inputToChars.get("ABC");
		break;
	}
	if (result == null) {
		result = (char[]) inputToChars.get("common");
	}
	if (result == null) {
		result = new char[0];
	}

	return result;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:23,代码来源:J2SEButton.java

示例3: TextField

import org.microemu.device.InputMethod; //导入依赖的package包/类
public TextField(String label, String text, int maxSize, int constraints) {
    super(label);
    super.setUI(DeviceFactory.getDevice().getUIFactory().createTextFieldUI(this));

    if (maxSize <= 0) {
        throw new IllegalArgumentException();
    }
    setConstraints(constraints);
    if (!InputMethod.validate(text, constraints)) {
        throw new IllegalArgumentException();
    }
    if (maxSize <= 0) {
        throw new IllegalArgumentException();
    }
    this.maxSize = maxSize;
    stringComponent = new StringComponent();
    if (text != null) {
        setString(text);
    } else {
        setString("");
    }
    stringComponent.setWidthDecreaser(8);
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:24,代码来源:TextField.java

示例4: setString

import org.microemu.device.InputMethod; //导入依赖的package包/类
void setString(String text, int caret) {
    if (!InputMethod.validate(text, constraints)) {
        throw new IllegalArgumentException("text  is illegal for the current input constraints");
    }
    if (text == null) {
        field = "";
        stringComponent.setText("");
    } else {
        if (text.length() > maxSize) {
            throw new IllegalArgumentException("text exceeds the current maximum capacity");
        }
        field = text;
        if ((constraints & PASSWORD) == 0) {
            stringComponent.setText(text);
        } else {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < text.length(); i++) {
                sb.append('*');
            }
            stringComponent.setText(sb.toString());
        }
    }
    setCaretPosition(caret);
    setCaretVisible(false);
    repaint();
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:27,代码来源:TextField.java

示例5: insert

import org.microemu.device.InputMethod; //导入依赖的package包/类
public void insert(String src, int position) {
    if (!InputMethod.validate(src, constraints)) {
        throw new IllegalArgumentException();
    }
    if (field.length() + src.length() > maxSize) {
        throw new IllegalArgumentException();
    }
    String newtext = "";
    if (position > 0) {
        newtext = ((AndroidTextFieldUI) ui).getString();
    }
    newtext += src;
    if (position < field.length()) {
        newtext += ((AndroidTextFieldUI) ui).getString().substring(position + 1);
    }
    ((AndroidTextFieldUI) ui).setString(newtext);
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:18,代码来源:TextField.java

示例6: filterInputMode

import org.microemu.device.InputMethod; //导入依赖的package包/类
protected char[] filterInputMode(char[] chars) {
    if (chars == null) {
        return new char[0];
    }
    
	int inputMode = getInputMode();
	char[] result = new char[chars.length];
	int i, j;

	for (i = 0, j = 0; i < chars.length; i++) {
		if (inputMode == InputMethod.INPUT_ABC_UPPER) {
			result[j] = Character.toUpperCase(chars[i]);
			j++;
		} else if (inputMode == InputMethod.INPUT_ABC_LOWER) {
			result[j] = Character.toLowerCase(chars[i]);
			j++;
		} else if (inputMode == InputMethod.INPUT_123) {
			if (Character.isDigit(chars[i]) || chars[i] == '-' || chars[i] == '.') {
				result[j] = chars[i];
				j++;
			}
		}
	}
	if (i != j) {
		char[] newresult = new char[j];
		System.arraycopy(result, 0, newresult, 0, j);
		result = newresult;
	}

	return result;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:32,代码来源:InputMethodImpl.java

示例7: paintControls

import org.microemu.device.InputMethod; //导入依赖的package包/类
public void paintControls(SwtGraphics g) {
	Device device = DeviceFactory.getDevice();

	g.setBackground(g.getColor(new RGB(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor
			.getBlue())));
	g.fillRectangle(0, 0, displayRectangle.width, displayPaintable.y);
	g.fillRectangle(0, displayPaintable.y, displayPaintable.x, displayPaintable.height);
	g.fillRectangle(displayPaintable.x + displayPaintable.width, displayPaintable.y, displayRectangle.width
			- displayPaintable.x - displayPaintable.width, displayPaintable.height);
	g.fillRectangle(0, displayPaintable.y + displayPaintable.height, displayRectangle.width,
			displayRectangle.height - displayPaintable.y - displayPaintable.height);

	g.setForeground(g.getColor(new RGB(foregroundColor.getRed(), foregroundColor.getGreen(), foregroundColor
			.getBlue())));
	for (Enumeration s = device.getSoftButtons().elements(); s.hasMoreElements();) {
		((SwtSoftButton) s.nextElement()).paint(g);
	}

	int inputMode = device.getInputMethod().getInputMode();
	if (inputMode == InputMethod.INPUT_123) {
		g.drawImage(((SwtImmutableImage) mode123Image.getImage()).getImage(), mode123Image.getRectangle().x,
				mode123Image.getRectangle().y);
	} else if (inputMode == InputMethod.INPUT_ABC_UPPER) {
		g.drawImage(((SwtImmutableImage) modeAbcUpperImage.getImage()).getImage(),
				modeAbcUpperImage.getRectangle().x, modeAbcUpperImage.getRectangle().y);
	} else if (inputMode == InputMethod.INPUT_ABC_LOWER) {
		g.drawImage(((SwtImmutableImage) modeAbcLowerImage.getImage()).getImage(),
				modeAbcLowerImage.getRectangle().x, modeAbcLowerImage.getRectangle().y);
	}
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:31,代码来源:SwtDeviceDisplay.java

示例8: paintControls

import org.microemu.device.InputMethod; //导入依赖的package包/类
public void paintControls(Graphics g) {
	Device device = DeviceFactory.getDevice();

	g.setColor(backgroundColor);
	g.fillRect(0, 0, displayRectangle.width, displayPaintable.y);
	g.fillRect(0, displayPaintable.y, displayPaintable.x, displayPaintable.height);
	g.fillRect(displayPaintable.x + displayPaintable.width, displayPaintable.y, displayRectangle.width
			- displayPaintable.x - displayPaintable.width, displayPaintable.height);
	g.fillRect(0, displayPaintable.y + displayPaintable.height, displayRectangle.width, displayRectangle.height
			- displayPaintable.y - displayPaintable.height);

	g.setColor(foregroundColor);
	for (Enumeration s = device.getSoftButtons().elements(); s.hasMoreElements();) {
		((J2SESoftButton) s.nextElement()).paint(g);
	}

	int inputMode = device.getInputMethod().getInputMode();
	if (inputMode == InputMethod.INPUT_123) {
		g.drawImage(((J2SEImmutableImage) mode123Image.getImage()).getImage(), mode123Image.getRectangle().x,
				mode123Image.getRectangle().y, null);
	} else if (inputMode == InputMethod.INPUT_ABC_UPPER) {
		g.drawImage(((J2SEImmutableImage) modeAbcUpperImage.getImage()).getImage(), modeAbcUpperImage
				.getRectangle().x, modeAbcUpperImage.getRectangle().y, null);
	} else if (inputMode == InputMethod.INPUT_ABC_LOWER) {
		g.drawImage(((J2SEImmutableImage) modeAbcLowerImage.getImage()).getImage(), modeAbcLowerImage
				.getRectangle().x, modeAbcLowerImage.getRectangle().y, null);
	}
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:29,代码来源:J2SEDeviceDisplay.java

示例9: setChars

import org.microemu.device.InputMethod; //导入依赖的package包/类
public void setChars(char[] data, int offset, int length) {
    if (data == null) {
        setString("");
    } else {
        if (length > maxSize) {
            throw new IllegalArgumentException();
        }
        String newtext = new String(data, offset, length);
        if (!InputMethod.validate(newtext, constraints)) {
            throw new IllegalArgumentException();
        }
        setString(newtext);
    }
    repaint();
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:16,代码来源:TextField.java

示例10: setConstraints

import org.microemu.device.InputMethod; //导入依赖的package包/类
public final void setConstraints(int constraints) {
    if ((constraints & TextField.CONSTRAINT_MASK) < ANY
            || (constraints & TextField.CONSTRAINT_MASK) > DECIMAL) {
        throw new IllegalArgumentException("constraints " + constraints + " is an illegal value");
    }
    this.constraints = constraints;
    if (!InputMethod.validate(getString(), constraints)) {
        setString("");
    }
    ((TextFieldUI) ui).setConstraints(constraints);
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:12,代码来源:TextField.java

示例11: setFocus

import org.microemu.device.InputMethod; //导入依赖的package包/类
@Override
void setFocus(boolean hasFocus) {
    super.setFocus(hasFocus);
    if (hasFocus) {
        // register input listener
        InputMethod inputMethod = DeviceFactory.getDevice().getInputMethod();
        inputMethod.setInputMethodListener(inputMethodListener);
        inputMethod.setMaxSize(getMaxSize());
        setCaretVisible(true);
    } else {
        // unregister input listener
        DeviceFactory.getDevice().getInputMethod().removeInputMethodListener(inputMethodListener);
        setCaretVisible(false);
    }
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:16,代码来源:TextField.java

示例12: showNotify

import org.microemu.device.InputMethod; //导入依赖的package包/类
@Override
void showNotify() {
    super.showNotify();
    InputMethod inputMethod = DeviceFactory.getDevice().getInputMethod();
    inputMethod.setInputMethodListener(inputMethodListener);
    inputMethod.setMaxSize(getMaxSize());
    setCaretPosition(getString().length());
    tf.setCaretVisible(true);
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:10,代码来源:TextBox.java

示例13: onCreate

import org.microemu.device.InputMethod; //导入依赖的package包/类
@Override
protected void onCreate(Bundle icicle) {
	super.onCreate(icicle);
	
	// Query the activity property android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
	TypedArray ta = getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowFullscreen });
	windowFullscreen = ta.getBoolean(0, false);
	
	Drawable phoneCallIcon = getResources().getDrawable(android.R.drawable.stat_sys_phone_call);
	int statusBarHeight = 0;
	if (!windowFullscreen) {
		statusBarHeight = phoneCallIcon.getIntrinsicHeight();
	}
	
       Display display = getWindowManager().getDefaultDisplay();
       final int width = display.getWidth();
       final int height = display.getHeight() - statusBarHeight;

       emulatorContext = new EmulatorContext() {

           private InputMethod inputMethod = new AndroidInputMethod();

           private DeviceDisplay deviceDisplay = new AndroidDeviceDisplay(MicroEmulatorActivity.this, this, width, height);
           
           private FontManager fontManager = new AndroidFontManager(getResources().getDisplayMetrics());

           public DisplayComponent getDisplayComponent() {
               // TODO consider removal of EmulatorContext.getDisplayComponent()
               System.out.println("MicroEmulator.emulatorContext::getDisplayComponent()");
               return null;
           }

           public InputMethod getDeviceInputMethod() {
               return inputMethod;
           }

           public DeviceDisplay getDeviceDisplay() {
               return deviceDisplay;
           }

           public FontManager getDeviceFontManager() {
               return fontManager;
           }

           public InputStream getResourceAsStream(Class origClass, String name) {
               try {
                   if (name.startsWith("/")) {
                       return MicroEmulatorActivity.this.getAssets().open(name.substring(1));
                   } else {
                       Package p = origClass.getPackage();
                       if (p == null) {
                           return MicroEmulatorActivity.this.getAssets().open(name);
                       } else {
                       	String folder = origClass.getPackage().getName().replace('.', '/');
                           return MicroEmulatorActivity.this.getAssets().open(folder + "/" + name);
                       }
                   }
               } catch (IOException e) {
                   Logger.debug(e);
                   return null;
               }
           }

           public boolean platformRequest(String url) throws ConnectionNotFoundException 
           {
               try {
                   startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
               } catch (ActivityNotFoundException e) {
                   throw new ConnectionNotFoundException();
               }

               return true;
           }
                   
       };
	
	activityThread = Thread.currentThread();
}
 
开发者ID:Helltar,项目名称:AMPASIDE,代码行数:79,代码来源:MicroEmulatorActivity.java

示例14: getInputMethod

import org.microemu.device.InputMethod; //导入依赖的package包/类
public InputMethod getInputMethod() {
	return emulatorContext.getDeviceInputMethod();
}
 
开发者ID:Helltar,项目名称:AMPASIDE,代码行数:4,代码来源:AndroidDevice.java

示例15: getInputMethod

import org.microemu.device.InputMethod; //导入依赖的package包/类
public InputMethod getInputMethod() {
	return context.getDeviceInputMethod();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:4,代码来源:DeviceImpl.java


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