1 7 8 package org.jdesktop.swing.utils; 9 10 import java.awt.Component ; 11 import java.awt.event.HierarchyEvent ; 12 import java.awt.event.HierarchyListener ; 13 14 import java.io.IOException ; 15 16 import org.jdesktop.swing.data.DefaultTableModelExt; 18 19 26 public class LoadOnShowListener implements HierarchyListener { 27 private DefaultTableModelExt data; 28 public LoadOnShowListener(DefaultTableModelExt data) { 29 this.data = data; 30 } 31 public void hierarchyChanged(HierarchyEvent event) { 32 Component component = (Component )event.getComponent(); 33 if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0 && 34 component.isShowing()) { 35 try { 36 data.startLoading(); 37 } catch (IOException e) { 38 System.out.println("could not load data: "+e.getMessage()); 40 e.printStackTrace(); 41 } 42 } 43 } 44 } 45 | Popular Tags |