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

📄 searchforsizelist.java

📁 Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套 代码
💻 JAVA
字号:
import javax.swing.JButton;import java.awt.Component;public class SearchForSizeList 							extends SimpleList<JButton> {	/**	post:	size() == 0 	 *          and iterator == 0		 */	public SearchForSizeList()  {		super();	}  	/**	post:	result == (this contains an item with identical 	 *						getWidth() and getHeight() values as c)	 *          and  iterator == 0 	 */	public boolean containsSameSize(JButton b)   {		boolean  found;		Component temp;		reset();		found = false;		while ( !found  &&  hasNext() )  {			temp = next();			found = (temp.getWidth()==b.getWidth() 						&& temp.getHeight()==b.getHeight());		}		reset();		return found;	}     	    /**	note:	This method is shown in Figure 11.16	 *	post:	containsSameSize(b) implies	 *				(result has the same dimensions as b	 *				 and the iterator is positioned after result)	 *			and (not containsSameSizeList(b))  implies 	 *				result == null 	 */	public JButton nextWithSameSize(JButton b)   {		boolean  found;		JButton tempButton = null;		found = false;		while ( !found  &&  hasNext() )  {			tempButton = next();			found = (tempButton.getWidth()==b.getWidth() 						&& tempButton.getHeight()==b.getHeight());		}		if (found)  			return tempButton;		else			return null;	} }

⌨️ 快捷键说明

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