⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch13s101.html

📁 详细介绍了jboss3.0的配置等
💻 HTML
📖 第 1 页 / 共 3 页
字号:
      file or directory selected a new instance of this class is created. </p><p>                 Classes to be imported </p><pre class="programlisting">  
                         import java.awt.BorderLayout; 
				 import java.awt.Component;
                         import java.beans.beancontext.BeanContextServicesSupport;
                         import java.io.File; 
				 import javax.swing.JPanel; 
				 import javax.swing.JLabel; 
				 import com.dreambean.ejx.FileManager;
                         import com.dreambean.ejx.FileManagerFactory; 
				 </pre><p> 
                 I am only so pitty about what classes are imported to show you at the header where the used
                 classes are coming from. 
                 Constructor of the class: </p><pre class="programlisting"> 
                         FileManagerImpl( FileManagerFactory pCaller ) { 
					mFactory = pCaller; 
				 } 
				 </pre><p>                 Methods must be overwriten by the class, The important part is the getComponent() method which
                 is called by the EJX framework to get the GUI component to be displayed. </p><pre class="programlisting"> 
                         public boolean isChanged() { 
					return true; 
				 } 
				 public void createNew() {
				 } 
				 public void load( File file ) throws Exception {
				 } 
				 public void save( File f ) throws Exception{
                         } 
				 public File getFile() { 
					return null; 
				 } 
				 public void setFile( File pFile ) {
				 } 
				 public FileManagerFactory getFactory() {
				  return mFactory; 
				 } 
				 public Component getComponent() {
					 JPanel lPane = new JPanel( new BorderLayout() ); 
					 lPane.add( new JLabel(
                             "&lt;HTML&gt;&lt;BODY&gt;&lt;H1&gt;Hello World&lt;/H1&gt;" 
					 + "&lt;H2&gt;Next Step&lt;/H2&gt;&lt;/BODY&gt;&lt;/HTML&gt;" ), 
						BorderLayout.CENTER ); 
				   return lPane;
				 }
                         </pre></div><div class="section"><a name="d0e11522"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11522"></a>Simple Component Example</h5></div></div><p>   
      This example can be found under "ejx/examples/simple.component". 
      This example is an introduction to AWT and how it can be used to define a GUI by the XML description file, compiled and
      display on the Panel in the EJX framework. To shorten the further discussion I only show the important stuff having
      changed or is new. </p><p>      The only thing with AWT you have to consider is that you have to use XMLBeans to compile the BeanInfo XML
      description into a Java class and then to compile it to a java bytecode class. For that have a look at the build.xml and look
      for xmlbeans. </p><p>      According to the AWT spec the only necessary thing you have to to is:</p><div class="orderedlist"><ol type="1"><li><p><a name="d0e11532"></a>Create an Bean Info XML description file like this: 

                         
                         &lt;bean class="com.madplanet.simpleComponent.MainPane"
                         displayname="Simple Component's Main Pane"
                         iconcolor16="/images/container.gif"&gt; &lt;property
                         name="FirstProperty" class="java.lang.String"
                         displayname="First Property"/&gt; &lt;property
                         name="SecondProperty" class="java.lang.String"
                         displayname="Second Property"/&gt; 
              </p></li><li><p><a name="d0e11535"></a>Create a GUI component class and add the GenericCustomizer to it (as parameter you have to
                 pass the class instance which is referred above (here it is
                 com.madplanet.singleComponent.MainPane). There are other classes you can use but at the
                 moment I have no more informations. </p></li><li><p><a name="d0e11538"></a>Compile all the java classes</p></li><li><p><a name="d0e11541"></a>User XMLBeans to create the java sourcecode from the XML beaninfo. The newly created java
                 classes are named like the referred class but with Beaninfo at the end (same package structure). </p></li><li><p><a name="d0e11544"></a>Compile the bean info java sourcecode files. </p></li></ol></div><p>      That's it. </p></div><div class="section"><a name="d0e11549"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11549"></a>FileManagerImpl</h5></div></div><p>Like the one before except the getComponent() method: </p><pre class="programlisting">              public Component getComponent() { // Create the Property Container and
                return its GUI component return new MainPane().getComponent(); 
	      } 
	      </pre></div><div class="section"><a name="d0e11556"></a><div class="titlepage"><div><h5 class="title"><a name="d0e11556"></a>MainPane</h5></div></div><p> This class now creates the GUI component using AWT to display the properties this class have.</p><p>                 Classes to be imported </p><pre class="programlisting">                         import java.awt.BorderLayout; 
				 import java.awt.Component;
                         import java.beans.beancontext.BeanContextSupport; 
				 import java.beans.beancontext.BeanContextChildComponentProxy;
                         import javax.swing.JPanel; 
				 import com.dreambean.awt.GenericCustomizer; 
				 </pre><p>                 This class has to supclass the BeanContextSupport </p><pre class="programlisting">                         public class MainPane extends BeanContextSupport </pre><p>                 There are the properties the Main Pane offer and which can then be set by GUI component defined
                 by the Bean Context Attention: All the properties in the BeanInfo XML file need here a public
                 getter and setter method with the appropriate type. </p><pre class="programlisting"> 
                         public String getFirstProperty() { 
					return mFirstProperty;
                         } 
				 public void setFirstProperty( String pToSet ) {
					mFirstProperty = pToSet; 
				 } 
				 public String getSecondProperty() { 
					return mSecondProperty; 
				 } 
				 public void setSecondProperty( String pToSet ) { 
					mSecondProperty = pToSet; 
				 }
				 </pre><p>   
                 This method returns the GUI component which contains the Generic Customizer need to display
                 the properties of this instance accordingly to the Bean Info XML description mentioned above.</p><pre class="programlisting">        		     public Component getComponent() { 
					JPanel lPane = new JPanel( new BorderLayout() );
				 lPane.add( new GenericCustomizer( this ), BorderLayout.CENTER ); 
				    return lPane; 
				 } 
			     </pre><p> 
      Eh voil&agrave;, that's it. When you build this example, start EJX and select Simple Component XML you will see two lines with
      the tag "First Property" and a Text Field (and also for Second Property).</p><p> 
      That's all for now. In the next step I will delf further into AWT and how you can use the Bean Info XML description to
      describe more advanced application. In addition I will then use the save() and load() method to load XML files which are
      the persistent part of a plugin. </p><p>   I anything is wrong or not correct please contact me at andreas.schaefer@madplanet.com. Also if you want to know more in
   detail or have a request for changes in this HowTo document. </p></div></div></div><div class="section"><a name="ejx3"></a><div class="titlepage"><div><h3 class="title"><a name="ejx3"></a>EJX/AWT GUI Basics HowTo</h3></div></div><div class="section"><a name="d0e11586"></a><div class="titlepage"><div><h4 class="title"><a name="d0e11586"></a>Introduction</h4></div></div><p>       In this How To I will discuss the use of the BeanContext und AWT to create GUIs and GUI components within
       EJX but you can also use AWT outside of EJX.Attention: please note that I always mean Rickard Oeberg's AWT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -