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

📄 toolbarbutton.java

📁 非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应用程序更漂亮更易操作。 官网:www.zkoss.org
💻 JAVA
字号:
/* Toolbarbutton.java{{IS_NOTE	Purpose:			Description:			History:		Thu Jun 23 11:33:45     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.xml.HTMLs;import org.zkoss.zk.ui.WrongValueException;import org.zkoss.zk.ui.event.Events;import org.zkoss.zul.impl.LabelImageElement;/** * A tool button. * * <p>The default CSS class is "button". * * <p>Non-xul extension: Toolbarbutton supports {@link #getHref}. If {@link #getHref} * is not null, the onClick handler is ignored and this element is degenerated * to HTML's A tag. * * @author tomyeh */public class Toolbarbutton extends LabelImageElement {	private String _orient = "horizontal", _dir = "normal";	private String _href, _target;	private int _tabindex = -1;	public Toolbarbutton() {	}	public Toolbarbutton(String label) {		setLabel(label);	}	public Toolbarbutton(String label, String image) {		setLabel(label);		setImage(image);	}	/** Returns the direction.	 * <p>Default: "normal".	 */	public String getDir() {		return _dir;	}	/** Sets the direction.	 * @param dir either "normal" or "reverse".	 */	public void setDir(String dir) throws WrongValueException {		if (!"normal".equals(dir) && !"reverse".equals(dir))			throw new WrongValueException(dir);		if (!Objects.equals(_dir, dir)) {			_dir = dir;			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 orient.	 * <p>Default: "horizontal".	 */	public String getOrient() {		return _orient;	}	/** Sets the orient.	 * @param orient either "horizontal" or "vertical".	 */	public void setOrient(String orient) throws WrongValueException {		if (!"horizontal".equals(orient) && !"vertical".equals(orient))			throw new WrongValueException("orient cannot be "+orient);		if (!Objects.equals(_orient, orient)) {			_orient = orient;			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 the tab order of this component.	 * <p>Default: -1 (means the same as browser's default).	 */	public int getTabindex() {		return _tabindex;	}	/** Sets the tab order of this component.	 */	public void setTabindex(int tabindex) throws WrongValueException {		if (_tabindex != tabindex) {			_tabindex = tabindex;			if (tabindex < 0) smartUpdate("tabindex", null);			else smartUpdate("tabindex", Integer.toString(_tabindex));		}	}	//-- super --//	public String getOuterAttrs() {		final StringBuffer sb =			new StringBuffer(64).append(super.getOuterAttrs());		appendAsapAttr(sb, Events.ON_FOCUS);		appendAsapAttr(sb, Events.ON_BLUR);		appendAsapAttr(sb, Events.ON_RIGHT_CLICK);			//no z.dbclk to avoid confusing			//no z.lfclk since it is handled by widget.js		if (_href == null) {			sb.append(" href=\"javascript:;\"");		} else {			sb.append(" href=\"")				.append(getDesktop().getExecution().encodeURL(_href))				.append('"');				//When hyper to other page, we always show progress dlg		}		HTMLs.appendAttribute(sb, "target", _target);		if (_tabindex >= 0)			HTMLs.appendAttribute(sb, "tabindex", _tabindex);		return sb.toString();	}}

⌨️ 快捷键说明

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