DemoPanel.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:3k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: DemoPanel.java,v 1.8 2005/06/28 13:18:25 kleopatra Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  */
  7. package org.jdesktop.demo;
  8. import java.awt.Container;
  9. import java.io.File;
  10. import javax.swing.BorderFactory;
  11. import javax.swing.Icon;
  12. import javax.swing.JMenuBar;
  13. import javax.swing.border.Border;
  14. import org.jdesktop.swingx.JXPanel;
  15. /**
  16.  *
  17.  * @author Richard Bair
  18.  */
  19. public abstract class DemoPanel extends JXPanel {
  20.     private Icon icon;
  21.     /**
  22.      * the border to use for lists. Set top/bottom only
  23.      */
  24.     protected Border listBorder = BorderFactory.createEmptyBorder(3, 0, 3, 0);
  25.     /**
  26.      * border to use for left/right margin in list.
  27.      */
  28.     protected Border marginBorder = BorderFactory.createEmptyBorder(0, 3, 0, 3);
  29.     /**
  30.      * the border to use for trees. 
  31.      */
  32.     protected Border treeBorder = BorderFactory.createEmptyBorder(3, 3, 3, 3);
  33.     /**
  34.      * the border to use for description editorpane in a titled panel:
  35.      * lines up with caption text. Ugly!
  36.      */
  37.     protected Border descriptionBorder =BorderFactory.createEmptyBorder(3, 12, 3, 3);
  38.     
  39.     /** Creates a new instance of DemoPanel */
  40.     public DemoPanel() {
  41.     }
  42.     
  43.     /**
  44.      * the description to use in the TOC.
  45.      * defaults to class name - implementations should override
  46.      * to return a handy description.
  47.      */
  48.     public String getName() {
  49.         // defaults to class name
  50.         String className = getClass().getName();
  51.         return className.substring(className.lastIndexOf(".")+1);
  52.     }
  53.  
  54.     /**
  55.      * the title to use in the information panel.
  56.      * defaults to getName();
  57.      * 
  58.      * @return
  59.      */
  60.     public String getInformationTitle() {
  61.         return getName();
  62.     }
  63.     
  64.     public File getSourceRootDir() {
  65.         try {
  66.             return new File(getClass().getResource("/sources").toURI());
  67.         } catch (Exception e) {
  68.             e.printStackTrace();
  69.             return null;
  70.         }
  71.     }
  72.     
  73.     public String getHowToURLString() {
  74.         // defaults JDNC documentation website
  75.         return "https://jdnc.dev.java.net/documentation/index.html";
  76.     }    
  77.     /**
  78.      * @return File object corresponding to html-ized view of source file
  79.      */
  80.     public File getSourceFile() {
  81.         try {
  82.             String relativeSourceDir = getClass().getName().replaceAll("\.", File.separator);
  83.             return new File(getSourceRootDir(), relativeSourceDir + ".java.html");
  84.         } catch (Exception e) {
  85.             e.printStackTrace();
  86.             return null;
  87.         }
  88.     }
  89.     public Icon getIcon() {
  90.         return icon;
  91.     }
  92.     
  93.     public void setIcon(Icon i) {
  94.         icon = i;
  95.     }
  96.     public void addMenuItems(JMenuBar menuBar) {
  97.     }
  98.     
  99.     /** 
  100.      * Returns an HTML-formatted string describing the demo; this can be several 
  101.      * sentences long. */
  102.     public String getHtmlDescription() {
  103.         return "<html>" + getName() + "</html>";
  104.     }
  105.     
  106.     /** 
  107.      * Returns a Container with the GUI for the demo. The Container will already
  108.      * be instantiated and configured, and not dependent on external components or
  109.      * configuration; ready-to-use and to add to a frame for display. 
  110.      */
  111.     public Container getContent() {
  112.         return this;
  113.     }
  114. }