FileDocCategorySizeDatePackage
JListView.javaAPI DocApache log4j 1.2.158917Sat Aug 25 00:09:34 BST 2007org.apache.log4j.gui

JListView

public class JListView extends JList

Fields Summary
static Category
cat
PatternLayout
layout
static LoggingEvent
proto
Constructors Summary
public JListView(JListViewModel model)


  
    
    super(model);
    layout = new PatternLayout("%r %p %c [%t] -  %m");
    //this.setModel(model);
    this.setCellRenderer(new MyCellRenderer());
    //    setFixedCellWidth(10);
    //setFixedCellHeight(20);

  
Methods Summary
public voidadd(org.apache.log4j.spi.LoggingEvent event)

    ((JListViewModel)getModel()).add(event);
  
public static voidmain(java.lang.String[] args)


    JFrame frame = new JFrame("JListView test");
    Container container = frame.getContentPane();

    JListView view = new JListView(new JListViewModel(Integer.parseInt(args[0])));


    JScrollPane sp = new JScrollPane(view);
    sp.setPreferredSize(new Dimension(250, 80));
    
    container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
    //container.add(view);
    container.add(sp);

    JButton b1 = new JButton("Add 1");
    JButton b10 = new JButton("Add 10");
    JButton b100 = new JButton("Add 100");
    JButton b1000 = new JButton("Add 1000");
    JButton b10000 = new JButton("Add 10000");

    JPanel panel = new JPanel(new GridLayout(0,1));
    container.add(panel);

    panel.add(b1);
    panel.add(b10);
    panel.add(b100);
    panel.add(b1000);
    panel.add(b10000);
    

    AddAction a1 = new AddAction(view, 1);
    AddAction a10 = new AddAction(view, 10);
    AddAction a100 = new AddAction(view, 100);
    AddAction a1000 = new AddAction(view, 1000);
    AddAction a10000 = new AddAction(view, 10000);

    b1.addActionListener(a1);
    b10.addActionListener(a10);
    b100.addActionListener(a100);
    b1000.addActionListener(a1000);
    b10000.addActionListener(a10000);

    frame.setVisible(true);
    frame.setSize(new Dimension(700,700));

    long before = System.currentTimeMillis();

    int RUN = 1000;
    int i = 0;
    while(i++ < RUN) {      
      LoggingEvent event0 = new LoggingEvent("x", cat, Priority.ERROR, 
					     "Message "+i, null);
      
      Throwable t = new Exception("hello "+i);
      LoggingEvent event1 = new LoggingEvent("x", cat, Priority.ERROR, 
					     "Message "+i, t);
      

      if(i % 10 == 0) {	
	event1.getThreadName();
	view.add(event1);
      } else {
	event0.getThreadName();
	view.add(event0);
      }
    }

    long after = System.currentTimeMillis();
    System.out.println("Time taken :"+ ((after-before)*1000/RUN));