1 package net.matuschek.jobo; 2 3 import java.util.Vector ; 4 5 import net.matuschek.swing.JHideFrame; 6 9 10 11 17 public class LogFrame extends JHideFrame { 18 19 private static final long serialVersionUID = 3177932656317752712L; 20 21 24 public LogFrame() { 25 listData = new Vector <String >(); 26 initComponents (); 27 pack (); 28 } 29 30 34 private void initComponents() { 35 buttonPanel = new java.awt.Panel (); 36 closeButton = new java.awt.Button (); 37 clearButton = new java.awt.Button (); 38 messagePanel = new javax.swing.JPanel (); 39 jScrollPane1 = new javax.swing.JScrollPane (); 40 messageList = new javax.swing.JList (); 41 setName("JoBo Logging"); 42 addWindowListener(new java.awt.event.WindowAdapter () { 43 public void windowClosing(java.awt.event.WindowEvent evt) { 44 exitForm(); 45 } 46 } 47 ); 48 closeButton.setLabel("Close"); 49 closeButton.addActionListener(new java.awt.event.ActionListener () { 50 public void actionPerformed(java.awt.event.ActionEvent evt) { 51 exitForm(); 52 } 53 } 54 ); 55 clearButton.setLabel("Clear"); 56 clearButton.addActionListener(new java.awt.event.ActionListener () { 57 public void actionPerformed(java.awt.event.ActionEvent evt) { 58 clearLog(); 59 } 60 } 61 ); 62 buttonPanel.add(clearButton); 63 buttonPanel.add(closeButton); 64 65 getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH); 66 67 messagePanel.setLayout(new javax.swing.BoxLayout (messagePanel, 0)); 68 69 jScrollPane1.setViewportView(messageList); 70 71 messagePanel.add(jScrollPane1); 72 73 getContentPane().add(messagePanel, java.awt.BorderLayout.CENTER); 74 75 } 76 77 public void addMsg(String msg) { 78 listData.add(msg); 79 80 if (listData.size() > maxLog) { 82 listData.remove(0); 83 } 84 85 messageList.setListData(listData); 86 } 87 88 public void clearLog() { 89 listData.clear(); 90 messageList.setListData(listData); 91 } 92 93 private Vector <String > listData = null; 94 private static int maxLog = 2000; 95 96 private java.awt.Panel buttonPanel; 97 private java.awt.Button closeButton; 98 private java.awt.Button clearButton; 99 private javax.swing.JPanel messagePanel; 100 private javax.swing.JScrollPane jScrollPane1; 101 private javax.swing.JList messageList; 102 } 103 | Popular Tags |