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

JTableAppender

public class JTableAppender extends JTable

Fields Summary
static Category
cat
PatternLayout
layout
Constructors Summary
public JTableAppender()


  
   
    layout = new PatternLayout("%r %p %c [%t] -  %m");
    this.setDefaultRenderer(Object.class, new Renderer());

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

    ((JTableAppenderModel)getModel()).add(event);
  
public java.awt.DimensiongetPreferredSize()

    System.out.println("getPreferredSize() called");
    return super.getPreferredSize();
  
public static voidmain(java.lang.String[] args)


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

    JTableAppender appender = new JTableAppender();
    
    JTableAppenderModel model = new 
                              JTableAppenderModel(Integer.parseInt(args[0]));
    appender.setModel(model);
    //appender.createDefaultColumnsFromModel();    


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

    JButton button = new JButton("ADD");
    container.add(button);
    

    button.addActionListener(new JTableAddAction(appender));

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

    long before = System.currentTimeMillis();

    int RUN = 10000;
    int i = 0;
    while(i++ < RUN) {      
      LoggingEvent event = new LoggingEvent("x", cat, Priority.ERROR, 
					    "Message "+i, null);
      event.getThreadName();
      if(i % 10 == 0) {
	//event.throwable = new Exception("hello "+i);
      }
      appender.add(event);
    }

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