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

📄 historylist.java

📁 这是《Java图形用户界面设计与实例》一书配套的源代码
💻 JAVA
字号:
//HistoryList.java//A doubly linked list, derived from List, holds a list of previously visited URL'spublic class HistoryList extends List{    private WebNode tail;    private WebNode current;    public HistoryList() {        super();        tail = null;    }    public void add(String url) {//将当前的网页URL加入记录        super.add(url);        if (size == 1) {            tail = head;            current = head;        }        else {            head.setPrev(current);            current.setNext(head);            current = head;            head.setNext(null);        }    }    public String getLast() throws Exception{//得到前一个网页        if(current.getPrev() != null)//访问过前一个网页,则显示            current = current.getPrev();        else            throw new Exception("无法后退!");//没有前一个网页,就出错        return current.getURL();    }    public String getNext() throws Exception{//前进网页        if(current.getNext() != null)//曾经后退,有前一个网页,就前进            current = current.getNext();        else            throw new Exception("不能前进!");//否则出错        return current.getURL();    }}

⌨️ 快捷键说明

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