📄 listpanel.java
字号:
package sfclasses;/* ---------------------------------------------------------------------- The SINUS Firewall -- a TCP/IP packet filter for Linux Written within the SINUS project at the University of Zurich, SWITCH, Telekurs Payserv AG, ETH Zurich. originally based on the sf Firewall Software (C) 1996 by Robert Muchsel and Roland Schmid. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. SINUS Firewall resources: SINUS Homepage: http://www.ifi.unizh.ch/ikm/SINUS/ Firewall Homepage: http://www.ifi.unizh.ch/ikm/SINUS/firewall.html Frequently asked questions: http://www.ifi.unizh.ch/ikm/SINUS/sf_faq.html Mailing list for comments, questions, bug reports: firewall@ifi.unizh.ch ---------------------------------------------------------------------- */import java.awt.*;import java.awt.event.*;import java.util.*;/** * <b>List Panel</b><br> * The list panel can be used to display arbitrary data stored in a vector * in table format. It is used to show filter rules and active TCP connections. * You have to derive subclasses of ListCanvas and of ListHeader and implement * the data dependent output in those classes. See FirewallAction.java and * RuleEditor.java for examples. * @see ListCanvas * @see ListHeader * @version 1.0 23 Jan 1997 * @author Roland E. Schmid */public class ListPanel extends Panel implements Refreshable, AdjustmentListener { private int canvas_width, canvas_height; private int offset_y; private int max_y; private Scrollbar vbar; private ListCanvas listCanvas; /** * Initialize new list panel. * @param listCanvas Canvas that implements data output * @param listHeader Canvas that draws the table header */ public ListPanel(ListCanvas listCanvas, ListHeader listHeader) { this.listCanvas = listCanvas; setLayout(new BorderLayout()); vbar = new Scrollbar(Scrollbar.VERTICAL); vbar.addAdjustmentListener(this); listCanvas.setHeader(listHeader); add("Center", listCanvas); add("East", vbar); add("North", listHeader); } public void adjustmentValueChanged(AdjustmentEvent ae) { switch(ae.getAdjustmentType()) { case AdjustmentEvent.UNIT_INCREMENT: case AdjustmentEvent.UNIT_DECREMENT: case AdjustmentEvent.BLOCK_INCREMENT: case AdjustmentEvent.BLOCK_DECREMENT: case AdjustmentEvent.TRACK: offset_y = ((Scrollbar)ae.getSource()).getValue(); listCanvas.setOffset(offset_y); break; } return; } // adjustmentValueChanged public void deselect() { listCanvas.deselect(); } public void refresh() { updateScrollbars(canvas_width, canvas_height); listCanvas.repaint(); } public void resetScrollOffset() { offset_y = 0; updateScrollbars(canvas_width, canvas_height); listCanvas.setOffset(offset_y); } protected void updateScrollbars(int cwidth, int cheight) { canvas_width = cwidth; canvas_height = cheight; max_y = listCanvas.getMaxY(); if (max_y < canvas_height) max_y = canvas_height; if (canvas_height >= 1) { vbar.setValues(offset_y, canvas_height, 0, max_y); vbar.setBlockIncrement(canvas_height / 2); vbar.setUnitIncrement(canvas_height / 10); } } } // ListPanel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -