All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sikuli.guide.HTMLTextPane Maven / Gradle / Ivy

/**
 *
 */
package org.sikuli.guide;

import java.awt.Dimension;
import javax.swing.JLabel;

import javax.swing.JTextPane;

class HTMLTextPane extends JTextPane {

  int maximum_width;
  String text;
  public Dimension preferredDimension;
  Visual comp = null;
  String htmltxt;

  public HTMLTextPane(Visual comp) {
    this.comp = comp;
    maximum_width = comp.maxWidth - 10;
    init();
  }

  public HTMLTextPane() {
    maximum_width = 400;
    init();
  }

  private void init() {
    setContentType("text/html");
  }

  @Override
  public void setText(String text) {
    this.text = text;
    if (comp != null) {
      maximum_width = comp.maxWidth - 2 * comp.PADDING_X;
      htmltxt = "
" + text + "
"; } else { htmltxt = ""+text+""; } super.setText(htmltxt); JTextPane tp = new JTextPane(); tp.setText(htmltxt); if (getPreferredSize().getWidth() > maximum_width) { // hack to limit the width of the text to width if (comp != null) { htmltxt = "
" + text + "
"; } else { htmltxt = "
"+text+"
"; } super.setText(htmltxt); } setSize(getPreferredSize()); } @Override public String getText() { return this.text; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy