1 7 package org.ejtools.adwt.service; 8 9 import java.awt.BorderLayout ; 10 import java.awt.Container ; 11 import java.awt.Dimension ; 12 import java.awt.Toolkit ; 13 import java.beans.beancontext.BeanContextServices ; 14 15 import javax.swing.JPanel ; 16 import javax.swing.WindowConstants ; 17 18 import org.apache.log4j.Logger; 19 20 27 public class SDIFrameServiceProvider extends FrameServiceProvider implements SDIFrameService 28 { 29 30 protected Container content = new JPanel (); 31 32 private static Logger logger = Logger.getLogger(SDIFrameServiceProvider.class); 33 34 35 36 public SDIFrameServiceProvider() 37 { 38 super(); 39 } 40 41 42 47 public void setContent(Container c) 48 { 49 this.content = c; 50 } 51 52 53 56 protected Class [] getServiceClass() 57 { 58 return new Class []{FrameService.class, SDIFrameService.class}; 59 } 60 61 62 63 protected void initializeBeanContextResources() 64 { 65 super.initializeBeanContextResources(); 66 67 BeanContextServices context = (BeanContextServices ) getBeanContext(); 68 69 frame.setSize(new Dimension (700, 500)); 70 71 this.scrollPane.getViewport().add(content); 72 this.frame.getContentPane().add(BorderLayout.CENTER, scrollPane); 73 74 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 75 this.frame.setLocation(screen.width / 2 - frame.getSize().width / 2, screen.height / 2 - frame.getSize().height / 2); 76 this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 77 78 this.useServices(context); 79 this.frame.setVisible(true); 80 81 logger.debug("SDIFrameService added"); 82 } 83 84 85 86 protected void releaseBeanContextResources() 87 { 88 super.releaseBeanContextResources(); 89 90 logger.debug("SDIFrameService removed"); 91 } 92 } 93 94 | Popular Tags |