⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inputcomponent.java

📁 FIRE (Flexible Interface Rendering Engine)是一个J2ME上的灵活的图形界面引擎
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		Vector lines = formatedText;				int rowHeight = font.getHeight();		int lineCount = lines.size();		int txtHeight = (rowHeight + LINE_DISTANCE)*lines.size();				// paint background if needed		if(backgroundColor!=Theme.TRANSPARENT)		{			g.setColor(backgroundColor);			g.fillRect(2,2,width-3,height-3);		}				for (int i = 0; i < lineCount && i<rows; ++i)		{			String str = (String) lines.elementAt(i);						if((textConstraints & TextField.PASSWORD) == TextField.PASSWORD)			{ // just draw a string of starts				int len = str.length();				str="";				for (int j = 0; j < len; ++j)					str += "*";			}						int x=0,y=0;			switch(valign)			{			case FireScreen.TOP:				y = (rowHeight+LINE_DISTANCE) * i +TEXT_BORDER;				break;			case FireScreen.VCENTER:				y = (height/2 - txtHeight/2) +  (rowHeight+LINE_DISTANCE) * i;				break;			case FireScreen.BOTTOM:				y = height - txtHeight +((rowHeight+LINE_DISTANCE) * i)-TEXT_BORDER;				break;				}						switch(halign)			{			case FireScreen.LEFT:				x =TEXT_BORDER;				break;			case FireScreen.CENTER:				x = width/2 - font.stringWidth(str)/2;				break;			case FireScreen.RIGHT:				x = width- font.stringWidth(str)-TEXT_BORDER;				break;			}						g.setColor(foregroundColor);			g.drawString(str,x, y, Graphics.TOP | Graphics.LEFT);		}		g.setColor(theme.getIntProperty("border.color"));		g.drawRect(2,2,width-4,height-4);				if(isSelected())		{			g.setColor(theme.getIntProperty("link.active.bg.color"));			g.drawRect(1,1,width-2,height-2);					}	}		private void paintRadioOrCheckbox(Graphics g)	{		Theme theme = FireScreen.getTheme();		int width = 0, height = 0;		if(getPrefSize()==null){			width = getWidth();			height = getHeight();		}else{			width = getPrefSize()[0];			height = getPrefSize()[1];		}		if(type==CHECKBOX)		{			if(checked)			{				g.setColor(theme.getIntProperty("bg.alt1.color"));				g.fillRect(2,2,width-4,height-4);				g.setColor(theme.getIntProperty("border.color"));				g.fillRect(5,5,width-9,height-9);			}			else			{				if(backgroundColor!=Theme.TRANSPARENT)				{					g.setColor(backgroundColor);					g.fillRect(2,2,width-4,height-4);				}			}						g.setColor(theme.getIntProperty("border.color"));			g.drawRect(2,2,width-4,height-4);		}		else		{			if(checked)			{				g.setColor(theme.getIntProperty("bg.alt1.color"));				g.fillArc(2,2,width-4,height-4,0,360);				g.setColor(theme.getIntProperty("border.color"));				g.fillArc(5,5,width-9,height-9,0,360);			}			else			{				if(backgroundColor!=Theme.TRANSPARENT)				{					g.setColor(backgroundColor);					g.fillArc(2,2,width-4,height-4,0,360);				}			}						g.setColor(theme.getIntProperty("border.color"));			g.drawArc(2,2,width-4,height-4,0,360);		}						if(isSelected())		{			g.setColor(theme.getIntProperty("link.active.bg.color"));			if(type==CHECKBOX)			{				g.drawRect(1,1,width-2,height-2);			}			else			{				g.drawArc(1,1,width-2,height-2,0,360);				g.drawArc(0,0,width,height,0,360);			}		}	}	public void reset()	{		if(type==CHECKBOX || type==RADIO) checked=(initialValue!=null);		else if(initialValue!=null){			value = initialValue;			formatedText=null;		}		repaint();	}	public byte getType()	{		return type;	}	public void setType(byte type)	{		this.type = type;	}	public int getSize()	{		return size;	}	public void setSize(int size)	{		this.size = size;	}	public int getMaxLen()	{		return maxLen;	}	public void setMaxLen(int maxLen)	{		this.maxLen = maxLen;	}	public String getName()	{		return name;	}	public void setName(String name)	{		this.name = name;	}	public String getValue()	{		return value;	}	public void setValue(String value)	{		this.value = value;		formatedText = null;		repaint();	}	public String getInitialValue()	{		return initialValue;	}	public void setInitialValue(String initialValue)	{		this.initialValue = initialValue;	}	public int getTextConstraints()	{		return textConstraints;	}	public void setTextConstraints(int textConstraints)	{		this.textConstraints = textConstraints;	}	public void addTextConstraints(int textConstraints)	{		this.textConstraints |= textConstraints;	}	public int getRows()	{		return rows;	}	public void setRows(int rows)	{		this.rows = rows;	}	public void setSelected(boolean v)	{		super.setSelected(v);		repaint();	}	public int[] getMinSize()	{		if(type==TEXT )		{			int w = font.charWidth('W')*size+(TEXT_BORDER*2);			if(w>maxWidth) w = maxWidth;			return new int[]{w,font.getHeight()*rows+(TEXT_BORDER*2)};		}		else if(type==BUTTON || type==RESET || type==SUBMIT )// type button or reset		{			int width = maxWidth-(TEXT_BORDER*2);					if(value!=null)			{				int tmp = font.stringWidth(value);				if(tmp<width) width=tmp;			}				return new int[]{width+(TEXT_BORDER*2),font.getHeight()*rows+(TEXT_BORDER*2)};		}else if(type==SWITCH || type==MENU)		{			int width = maxWidth-(SWITCH_BORDER*2);					if(text!=null)			{				int tmp = font.stringWidth(text);				if(tmp<width) width=tmp;			}			return new int[]{width+(SWITCH_BORDER*2),font.getHeight()*rows+(SWITCH_BORDER*2)};					}		return new int[]{RADIO_WIDTH,RADIO_HEIGHT};	}	public int getContentWidth()	{		if (!valid)			throw new IllegalStateException("The element is not validated.");				return getPrefSize()[0];	}	public int getContentHeight()	{		if (!valid)			throw new IllegalStateException("The element is not validated.");				return getPrefSize()[1];	}			protected void pointerReleased(int x, int y)	{		if(command!=null && commandListener!=null)		{			setSelected(!isSelected());			if(isSelected() // component just became selected or  					|| type==BUTTON) // if type==button. Do not act as switch, every pointer event on a button must result to an commandAction event. 			{				commandListener.commandAction(command,this);			}		}		super.pointerReleased(x, y);	}		private boolean keyPressed = false;	//This is needed because some nokia phones have there "Ok" in the middle, which will case	//the TextArea to appear again. 	protected void keyPressed(int keyCode){		keyPressed = true;		super.keyPressed(keyCode);	}		private void handleKeyEvent(int keyCode)	{		int key = FireScreen.getScreen().getGameAction(keyCode);		if((key==Canvas.LEFT|| key==Canvas.DOWN ||key==Canvas.RIGHT || key==Canvas.UP))		{			setSelected(!isSelected());		}		else if( command!=null && commandListener!=null && (type==TEXT||key==Canvas.FIRE) && keyPressed) 			commandListener.commandAction(command,this);		keyPressed = false;			}	protected void keyRepeated(int keyCode)	{		handleKeyEvent(keyCode);		super.keyRepeated(keyCode);	}		protected void keyReleased(int keyCode)	{		handleKeyEvent(keyCode);		super.keyReleased(keyCode);	}		public boolean isEnabled()	{		return enabled;	}	public void setEnabled(boolean enabled)	{		this.enabled = enabled;	}	public boolean isChecked()	{		return checked;	}	public void setChecked(boolean checked)	{		this.checked = checked;	}	public String getText()	{		return text;	}	public void setText(String text)	{		this.text = text;	}	public int getMaxWidth()	{		return maxWidth;	}	public void setMaxWidth(int maxWidth)	{		this.maxWidth = maxWidth;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -