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

📄 menuitem.java

📁 非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应用程序更漂亮更易操作。 官网:www.zkoss.org
💻 JAVA
字号:
/* Menuitem.java{{IS_NOTE	Purpose:			Description:			History:		Thu Sep 22 10:58:23     2005, Created by tomyeh}}IS_NOTECopyright (C) 2005 Potix Corporation. All Rights Reserved.{{IS_RIGHT	This program is distributed under GPL Version 2.0 in the hope that	it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*/package org.zkoss.zul;import org.zkoss.lang.Objects;import org.zkoss.zk.ui.Component;import org.zkoss.zk.ui.UiException;import org.zkoss.zk.ui.WrongValueException;import org.zkoss.zk.ui.ext.client.Checkable;import org.zkoss.zul.impl.LabelImageElement;/** * sA single choice in a {@link Menupopup} element. * It acts much like a button but it is rendered on a menu. * * @author tomyeh */public class Menuitem extends LabelImageElement {	private String _value = "";	private String _href, _target;	private boolean _autocheck, _checked;	public Menuitem() {	}	public Menuitem(String label) {		setLabel(label);	}	public Menuitem(String label, String src) {		setLabel(label);		setImage(src);	}	/** Returns the value.	 * <p>Default: "".	 */	public String getValue() {		return _value;	}	/** Sets the value.	 */	public void setValue(String value) {		if (value == null)			value = "";		_value = value; //no need to update client	}	/** Returns whether it is checked.	 * <p>Default: false.	 */	public boolean isChecked() {		return _checked;	}	/** Sets whether it is checked.	 */	public void setChecked(boolean checked) {		if (_checked != checked) {			_checked = checked;			final Component parent = getParent();			if (parent instanceof Menupopup)				parent.invalidate();			//FUTURE: to support checked for top-level menuitems		}	}	/** Returns whether the menuitem check mark will update each time	 * the menu item is selected	 * <p>Default: false.	 */	public boolean isAutocheck() {		return _autocheck;	}	/** Sets whether the menuitem check mark will update each time	 * the menu item is selected	 */	public void setAutocheck(boolean autocheck) {		if (_autocheck != autocheck) {			_autocheck = autocheck;			invalidate();		}	}	/** Returns the href.	 * <p>Default: null. If null, the button has no function unless you	 * specify the onClick handler.	 */	public String getHref() {		return _href;	}	/** Sets the href.	 */	public void setHref(String href) throws WrongValueException {		if (href != null && href.length() == 0)			href = null;		if (!Objects.equals(_href, href)) {			_href = href;			invalidate();		}	}	/** Returns the target frame or window.	 *	 * <p>Note: it is useful only if href ({@link #setHref}) is specified	 * (i.e., use the onClick listener).	 *	 * <p>Default: null.	 */	public String getTarget() {		return _target;	}	/** Sets the target frame or window.	 * @param target the name of the frame or window to hyperlink.	 */	public void setTarget(String target) {		if (target != null && target.length() == 0)			target = null;		if (!Objects.equals(_target, target)) {			_target = target;			smartUpdate("target", _target);		}	}	/** Returns whether this is an top-level menu, i.e., not owning	 * by another {@link Menupopup}.	 */	public boolean isTopmost() {		return !(getParent() instanceof Menupopup);	}	//-- Super --//	public String getOuterAttrs() {		final String attrs = super.getOuterAttrs();		boolean topmost = isTopmost();		if (!topmost && !_autocheck) return attrs;		final StringBuffer sb = new StringBuffer(64).append(attrs);		if (topmost) sb.append(" z.top=\"true\"");		if (_autocheck) {			sb.append(" z.autock=\"true\"");			if (_checked) sb.append(" z.checked=\"true\"");		}		return sb.toString();	}	protected String getRealStyle() {		final String style = super.getRealStyle();		return isTopmost() ?			style + "padding-left:4px;padding-right:4px;": style;	}	//-- Component --//	public void setParent(Component parent) {		if (parent != null && !(parent instanceof Menupopup)		&& !(parent instanceof Menubar))			throw new UiException("Unsupported parent for menuitem: "+parent);		super.setParent(parent);	}	/** Not childable. */	public boolean isChildable() {		return false;	}	//-- ComponentCtrl --//	protected Object newExtraCtrl() {		return new ExtraCtrl();	}	/** A utility class to implement {@link #getExtraCtrl}.	 * It is used only by component developers.	 */	protected class ExtraCtrl extends LabelImageElement.ExtraCtrl	implements Checkable {		//-- Checkable --//		public void setCheckedByClient(boolean checked) {			setChecked(checked);		}	}}

⌨️ 快捷键说明

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