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

📄 scalingeditor.java

📁 程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件
💻 JAVA
字号:
package examples.beans;
import java.beans.*;
/** This class provides the editing support for the
  * scaling property of the ImageBean3 class.
  */
public class ScalingEditor extends PropertyEditorSupport {
   /** Provide the names of the allowable values.
     * Don't put spaces in these tags - the Sun
     * BeanBox chokes on them.  
     * @return An array of strings containing the
     *         allowable values
     */
   public String[] getTags() {
      return new String[] { "original_size",
                            "scaled_to_fit" };
   }
   /** Convert a tag string into a tag name into a
     * value.  The default is to set the value to
     * the ORIGINAL_SIZE value.
     * @param s The tag string
     */
   public void setAsText( String s ) {
      if ( s.equals( "scaled_to_fit" ) ) {
         setValue( new Integer(
                       ImageBean3.SCALED_TO_FIT) );
      } else {
         setValue( new Integer(
                       ImageBean3.ORIGINAL_SIZE) );
      }
   }
   /** For a given property value, return a string
     * that can be used for code generation.  The
     * default value returned is the string for the
     * ORIGINAL_SIZE value.
     * @return The string put into the generated code
     */
   public String getJavaInitializationString() {
      switch( ( (Number) getValue() ).intValue() ) {
         default:
         case ImageBean3.ORIGINAL_SIZE:
            return "examples.beans.ImageBean3."
                   +"ORIGINAL_SIZE";
         case ImageBean3.SCALED_TO_FIT:
            return "examples.beans.ImageBean3."
                   +"SCALED_TO_FIT";
      }
   }
}

⌨️ 快捷键说明

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