📄 isorequestlistenerpanel.java
字号:
/* * jPOS Project [http://jpos.org] * Copyright (C) 2000-2008 Alejandro P. Revilla * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */package org.jpos.iso.gui;import java.awt.BorderLayout;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Insets;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import java.util.Observable;import java.util.Observer;import javax.swing.BorderFactory;import javax.swing.DefaultListModel;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.ListModel;import org.jpos.iso.ISOMsg;import org.jpos.iso.ISORequestListener;public class ISORequestListenerPanel extends JPanel implements Observer { private static final long serialVersionUID = -1786048717180010741L; /** * @serial */ DefaultListModel log; /** * @serial */ String symbolicName; public static final int LOG_CAPACITY = 250; public ISORequestListenerPanel ( ISORequestListener requestListener, String symbolicName) { super(); this.symbolicName = symbolicName; setLayout(new FlowLayout()); setBorder(BorderFactory.createRaisedBevelBorder()); log = new DefaultListModel(); add(createPanel()); if (requestListener instanceof Observable) ((Observable)requestListener).addObserver(this); } public final String getSymbolicName() { return symbolicName; } public final ListModel getLog() { return log; } public void update(Observable o, Object arg) { if (arg != null && arg instanceof ISOMsg) { ISOMsg m = (ISOMsg) arg; log.addElement(m); if (log.getSize() > LOG_CAPACITY) log.remove(0); } } private JPanel createPanel() { JPanel A = new JPanel() { private static final long serialVersionUID = -6042644671679973897L; public Insets getInsets() { return new Insets(10,10,10,10); } }; A.setLayout(new BorderLayout()); JLabel l = new JLabel(symbolicName); A.add(l, BorderLayout.NORTH); final JList logList = new JList(log); logList.setPrototypeCellValue("9999 99999999 999999"); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { ISOMsg m = (ISOMsg) logList.getSelectedValue(); if (m != null) { JFrame f = new JFrame(m.toString()); ISOMsgPanel p = new ISOMsgPanel(m); f.getContentPane().add(p); f.pack(); f.show(); } } }; logList.addMouseListener(mouseListener); JScrollPane scrollPane = new JScrollPane(logList); scrollPane.setPreferredSize(new Dimension(170,200)); A.add(scrollPane, BorderLayout.SOUTH); return A; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -