Package util.ui.beanshell

Source Code of util.ui.beanshell.BeanShellEditor

/*
* Created on 01.11.2004
*/
package util.ui.beanshell;

import java.awt.Dimension;

import javax.swing.JEditorPane;
import javax.swing.JViewport;
import javax.swing.plaf.TextUI;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import javax.swing.text.StyledEditorKit;

/**
* A TextArea for BeanShell-Skripts. Including Syntax-Highlighting
*
* @author bodum
*/
public class BeanShellEditor extends JEditorPane {

  /**
   * Create the TextArea
   */
  public BeanShellEditor() {
    setDocument(new SyntaxDocument());

    EditorKit editorKit = new StyledEditorKit() {
      public Document createDefaultDocument() {
        return new SyntaxDocument();
      }
    };

    setEditorKitForContentType("text/beanshell", editorKit);
    setContentType("text/beanshell");
   
   
  }

  /**
   * Override to get no Line-Wraps
   */
  public boolean getScrollableTracksViewportWidth() {
    if (getParent() instanceof JViewport) {
      JViewport port = (JViewport) getParent();
      TextUI textUI = getUI();
      int w = port.getWidth();
      textUI.getMinimumSize(this);
      textUI.getMaximumSize(this);
      Dimension pref = textUI.getPreferredSize(this);
     
      if ((w >= pref.width)) {
        return true;
      }
    }
    return false;
  }

}
TOP

Related Classes of util.ui.beanshell.BeanShellEditor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.