titlepositioneditor.java

来自「core java verion 8 source code」· Java 代码 · 共 38 行

JAVA
38
字号
package com.horstmann.corejava;

import java.beans.*;
import java.util.*;

/**
 * A custom editor for the titlePosition property of the ChartBean. The editor lets the user choose
 * between Left, Center, and Right
 * @version 1.20 2007-12-14
 * @author Cay Horstmann
 */
public class TitlePositionEditor extends PropertyEditorSupport
{
   public String[] getTags()
   {
      return tags;
   }

   public String getJavaInitializationString()
   {
      return ChartBean.Position.class.getName().replace('$', '.') + "." + getValue();
   }

   public String getAsText()
   {
      int index = ((ChartBean.Position) getValue()).ordinal();
      return tags[index];
   }

   public void setAsText(String s)
   {
      int index = Arrays.asList(tags).indexOf(s);
      if (index >= 0) setValue(ChartBean.Position.values()[index]);
   }

   private String[] tags = { "Left", "Center", "Right" };
}

⌨️ 快捷键说明

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