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

📄 pagecounter.java

📁 textviewer 一个手机上的文本浏览器实现
💻 JAVA
字号:
package textViewer;// TODO: implement as RangedIntegerpublic class PageCounter {    private int page;    private PageChangable callback;    private int min;    private int max;    public PageCounter(PageChangable callback, int page, int min, int max)     {    	this.callback = callback;	this.page = page;	this.min = min;	this.max = max;    }    public PageCounter(PageChangable callback)     {	this(callback, 1,1,1);     }    public int getMax()    {	return max;    }    public void setMax(int max)    {	this.max = max;    }    public int getValue()     {	return page;    }    public void setValueWithErrors(int newPage) throws IndexOutOfBoundsException    {	if ( (newPage >= min) && (newPage <= max) )	    {		page = newPage;		callback.pageChanged();	    }	else {throw new IndexOutOfBoundsException("PageCounter.setValueWithErrors: requested page number " + Integer.toString(newPage) + " is not in between minimum limit " + Integer.toString(min) + " and maximum limit " + Integer.toString(max));}    }	    public void setValue(int newPage)    {	try {	    setValueWithErrors(newPage);	} catch (IndexOutOfBoundsException e) {}    }    public void add(int arg)     {	setValue(getValue() + arg);    }    public void addAsFarAsYouCan(int arg)     {	try {	    setValueWithErrors(getValue() + arg);	}	catch (IndexOutOfBoundsException e) 	    {		if (arg > 0) {setValue(max);}		else if (arg < 0) {setValue(min);}	    }    }}

⌨️ 快捷键说明

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