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

📄 xbackforwardhistorypopup.java

📁 XBrowser是一个完全免费并且开源的Web浏览器
💻 JAVA
字号:
/****************************************************************
*              XBrowser  -  eXtended web Browser                *
*                                                               *
*           Copyright (c) 2000-2001  Armond Avanes              *
*     Refer to ReadMe & License files for more information      *
*                                                               *
*                                                               *
*                      By: Armond Avanes                        *
*       Armond555@yahoo.com     &    Armond333@yahoo.com        *
*                http://xbrowser.sourceforge.net/               *
*****************************************************************/
package xbrowser.widgets;

import javax.swing.*;
import java.awt.event.*;
import java.util.*;

import xbrowser.doc.*;
import xbrowser.renderer.*;

public class XBackForwardHistoryPopup extends JPopupMenu implements ActionListener
{
	public XBackForwardHistoryPopup(int history_type)
	{
		historyType = history_type;
	}

	public void setDocument(XDocument doc)
	{
		this.doc = doc;
		update();
	}

	public void update()
	{
		removeAll();

		if( doc==null )
			return;

	JMenuItem menu_item = null;
	Iterator it = null;

		if( historyType==XRenderer.FORWARD_HISTORY )
		{
			if( doc.getRenderer().hasForwardHistory() )
			{
				it = doc.getRenderer().getForwardHistory();

				while( it.hasNext() )
				{
					menu_item = new JMenuItem( (String)it.next() );
					menu_item.addActionListener(this);
					add(menu_item);
				}
			}
		}
		else
		{
			if( doc.getRenderer().hasBackwardHistory() )
			{
				it = doc.getRenderer().getBackwardHistory();

				while( it.hasNext() )
				{
					menu_item = new JMenuItem( (String)it.next() );
					menu_item.addActionListener(this);
					insert(menu_item, 0);
				}
			}
		}
	}

	public void actionPerformed(ActionEvent e)
	{
	int index = getComponentIndex((JMenuItem)e.getSource());

		if( historyType==XRenderer.BACKWARD_HISTORY)
			index = getComponentCount() - index - 1;

		doc.getRenderer().showPageFromHistory(index, historyType);
	}

// Attribute:
	private XDocument doc = null;
	private int historyType = XRenderer.BACKWARD_HISTORY;
}

⌨️ 快捷键说明

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