當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicHTML.createHTMLView方法代碼示例

本文整理匯總了Java中javax.swing.plaf.basic.BasicHTML.createHTMLView方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicHTML.createHTMLView方法的具體用法?Java BasicHTML.createHTMLView怎麽用?Java BasicHTML.createHTMLView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.plaf.basic.BasicHTML的用法示例。


在下文中一共展示了BasicHTML.createHTMLView方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: componentAdded

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
@Override
public void componentAdded(ContainerEvent e) {
	JTabbedPane tp = (JTabbedPane) e.getContainer();
	Component child = e.getChild();
	if (child instanceof UIResource) {
		return;
	}
	int index = tp.indexOfComponent(child);
	String title = tp.getTitleAt(index);
	boolean isHTML = BasicHTML.isHTMLString(title);
	if (isHTML) {
		if (htmlViews == null) { // Initialize vector
			htmlViews = createHTMLVector();
		}
		else { // Vector already exists
			View v = BasicHTML.createHTMLView(tp, title);
			htmlViews.insertElementAt(v, index);
		}
	}
	else { // Not HTML
		if (htmlViews != null) { // Add placeholder
			htmlViews.insertElementAt(null, index);
		} // else nada!
	}
}
 
開發者ID:MyersResearchGroup,項目名稱:iBioSim,代碼行數:26,代碼來源:CloseTabPaneUI.java

示例2: init

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
private void init(String text) {
  setForeground(FONT_COLOR);

  View v = BasicHTML.createHTMLView(this, String.format("<html>%s</html>", text));
  float width = v.getPreferredSpan(View.X_AXIS);
  isMultiline = isMultiline || width > MAX_WIDTH;
  setText(width > MAX_WIDTH ?
          String.format("<html><div width=%d>%s</div></html>", MAX_WIDTH, text) :
          String.format("<html>%s</html>", text));

  if (width > MAX_WIDTH) {
    v = (View)getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
      width = 0.0f;
      for(View row : getRows(v)) {
        float rWidth = row.getPreferredSpan(View.X_AXIS);
        if (width < rWidth) {
          width = rWidth;
        }
      }

      v.setSize(width, v.getPreferredSpan(View.Y_AXIS));
    }
  }
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:26,代碼來源:HelpTooltip.java

示例3: render

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
public static BufferedImage render( Color color, Font font, String html ) {
            JLabel label = new JLabel( html );
            label.setFont( font );
            label.setForeground( color );
            View htmlView = BasicHTML.createHTMLView( label, html );

            Dimension dim = label.getPreferredSize();
            if ( dim.width == 0 || dim.height == 0 ) {
                return null;
            }

            BufferedImage image = new BufferedImage( dim.width, dim.height, BufferedImage.TYPE_INT_ARGB );
            final Graphics2D g = image.createGraphics();
            g.setColor( new Color( 255, 255, 255, 0 ) );//transparent background
            g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
            g.setRenderingHint( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
            g.setRenderingHint( RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY );
            g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE );
//            g.setRenderingHint( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY );//this fails.
            g.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
            Rectangle s = new Rectangle( dim );
            g.fill( s );
            g.setClip( s );
            htmlView.paint( g, s );
            //the label should go out of scope, no harm done...
            return image;
        }
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:28,代碼來源:HTMLGraphic.java

示例4: update

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
 * Applies all properties to the underlying JLabel, creates an htmlView and
 * updates bounds.
 */
private void update() {
    String htmlContent = label.getText();
    if (htmlContent == null) {
        htmlContent = "";
    }

    htmlView = BasicHTML.createHTMLView(label, htmlContent);
    fitHeightToHtmlContent();

    repaint();
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:16,代碼來源:PHtmlView.java

示例5: componentAdded

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
public void componentAdded(ContainerEvent e) {
    JTabbedPane tp = (JTabbedPane) e.getContainer();
    TabbedPaneLayout layout = (TabbedPaneLayout) tp.getLayout();
    layout.layoutContainer(tp);

    Component child = e.getChild();
    if (child instanceof UIResource) {
        return;
    }
    int index = tp.indexOfComponent(child);
    String title = tp.getTitleAt(index);
    boolean isHTML = BasicHTML.isHTMLString(title);
    if (isHTML) {
        if (htmlViews == null) {
            // Initialize vector
            htmlViews = createHTMLViewList();
        } else {
            // Vector already exists
            View v = BasicHTML.createHTMLView(tp, title);
            htmlViews.add(index, v);
        }
    } else {
        // Not HTML
        if (htmlViews != null) {
            // Add placeholder
            htmlViews.add(index, null);
        } // else nada!
    }
}
 
開發者ID:Gocnak,項目名稱:Botnak,代碼行數:30,代碼來源:BaseTabbedPaneUI.java

示例6: propertyChange

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
public void propertyChange(PropertyChangeEvent e) {
    JTabbedPane pane = (JTabbedPane) e.getSource();
    String name = e.getPropertyName();
    boolean isScrollLayout = scrollableTabLayoutEnabled();
    if ("mnemonicAt".equals(name)) {
        updateMnemonics();
        pane.repaint();
    } else if ("displayedMnemonicIndexAt".equals(name)) {
        pane.repaint();
    } else if ("indexForTitle".equals(name)) {
        int index = (Integer) e.getNewValue();
        String title = tabPane.getTitleAt(index);
        if (BasicHTML.isHTMLString(title)) {
            if (htmlViews == null) {    // Initialize vector
                htmlViews = createHTMLViewList();
            } else {                  // Vector already exists
                View v = BasicHTML.createHTMLView(tabPane, title);
                htmlViews.set(index, v);
            }
        } else {
            if (htmlViews != null && htmlViews.get(index) != null) {
                htmlViews.set(index, null);
            }
        }
        updateMnemonics();
    } else if ("tabLayoutPolicy".equals(name)) {
        BaseTabbedPaneUI.this.uninstallUI(pane);
        BaseTabbedPaneUI.this.installUI(pane);
    } else if ("background".equals(name) && isScrollLayout) {
        Color newVal = (Color) e.getNewValue();
        tabScroller.tabPanel.setBackground(newVal);
        tabScroller.viewport.setBackground(newVal);
        Color newColor = selectedColor == null ? newVal : selectedColor;
        tabScroller.scrollForwardButton.setBackground(newColor);
        tabScroller.scrollBackwardButton.setBackground(newColor);
    } else if ("indexForTabComponent".equals(name)) {
        if (tabContainer != null) {
            tabContainer.removeUnusedTabComponents();
        }
        try {
            Component tabComponent = getTabComponentAt((Integer) e.getNewValue());
            if (tabComponent != null) {
                if (tabContainer == null) {
                    installTabContainer();
                } else {
                    addMyPropertyChangeListeners(tabComponent);
                    tabContainer.add(tabComponent);
                }
            }
        } catch (Exception ex) {
        }
        tabPane.revalidate();
        tabPane.repaint();
    } else if ("componentOrientation".equals(name)) {
        pane.revalidate();
        pane.repaint();
    } else if ("tabAreaBackground".equals(name)) {
        pane.revalidate();
        pane.repaint();
    }
}
 
開發者ID:Gocnak,項目名稱:Botnak,代碼行數:62,代碼來源:BaseTabbedPaneUI.java


注:本文中的javax.swing.plaf.basic.BasicHTML.createHTMLView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。