本文整理匯總了Java中javax.swing.plaf.basic.BasicHTML.isHTMLString方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicHTML.isHTMLString方法的具體用法?Java BasicHTML.isHTMLString怎麽用?Java BasicHTML.isHTMLString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.plaf.basic.BasicHTML
的用法示例。
在下文中一共展示了BasicHTML.isHTMLString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setDisplayName
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/** Sets localized display name of this <code>TopComponent</code>.
* @param displayName localized display name which is set
* @since 4.13 */
public void setDisplayName(String displayName) {
String old = this.displayName;
if ((displayName == old) || ((displayName != null) && displayName.equals(old))) {
return;
}
// warning if display name contains html tags
if (BasicHTML.isHTMLString(displayName)) {
Logger.getAnonymousLogger().warning(
"Call of " + getClass().getName() + ".setDisplayName(\"" + displayName + "\")" +
" shouldn't contain any HTML tags. Please use " + getClass().getName() + ".setHtmlDisplayName(String)" +
"for such purpose. For details please see http://www.netbeans.org/issues/show_bug.cgi?id=66777.");
}
this.displayName = displayName;
firePropertyChange("displayName", old, displayName); // NOI18N
WindowManager.getDefault().topComponentDisplayNameChanged(this, displayName);
}
示例2: 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!
}
}
示例3: createHTMLVector
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
private Vector<View> createHTMLVector() {
Vector<View> htmlViews = new Vector<View>();
int count = tabPane.getTabCount();
if (count > 0) {
for (int i = 0; i < count; i++) {
String title = tabPane.getTitleAt(i);
if (BasicHTML.isHTMLString(title)) {
htmlViews.addElement(BasicHTML.createHTMLView(tabPane, title));
}
else {
htmlViews.addElement(null);
}
}
}
return htmlViews;
}
示例4: htmlHack
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
* A hack to prepare HTML-based Swing components: size initialization is called inside paint method.
* @param g a non-null Graphics object
* @param component an HTML-based component that needs to be initialized
* @param cellRect a space where the component should be painted
*/
public static void htmlHack( Graphics g, Component component, Rectangle cellRect ) {
String text;
if ( component instanceof JLabel )
text = ( ( JLabel )component ).getText();
else if ( component instanceof AbstractButton )
text = ( ( AbstractButton )component ).getText();
else if ( component instanceof JToolTip )
text = ( ( JToolTip )component ).getTipText();
else
text = null;
if ( !BasicHTML.isHTMLString( text ) )
return;
component.setBounds( cellRect );
Graphics gg = g.create( -cellRect.width, -cellRect.height, cellRect.width, cellRect.height );
try {
component.paint( gg );
} catch ( NullPointerException e ) {
// Thrown on applet reinitialization.
} finally {
gg.dispose();
}
}
示例5: buildDimensions
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
private JLabel buildDimensions() {
// Build and return a JLabel if we need to render HTML,
// then determine the dimensions of the label.
final JLabel label;
if (BasicHTML.isHTMLString(txt)) {
label = new JLabel(txt);
label.setForeground(fg);
label.setFont(font);
size = label.getPreferredSize();
label.setSize(size);
}
else {
label = null;
final Graphics2D g = ImageUtils.NULL_IMAGE.createGraphics();
final FontMetrics fm = g.getFontMetrics(font);
size = new Dimension(fm.stringWidth(txt), fm.getHeight());
g.dispose();
}
return label;
}
示例6: updateTitle
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/** Actually sets title for the frame
*/
@Override
public void updateTitle(String title) {
// extract HTML from text - Output window (and soon others) uses it
if (BasicHTML.isHTMLString(title)) {
char[] c = title.toCharArray();
StringBuffer sb = new StringBuffer(title.length());
boolean inTag = false;
for (int i=0; i < c.length; i++) {
if (inTag && c[i] == '>') { //NOI18N
inTag = false;
continue;
}
if (!inTag && c[i] == '<') { //NOI18N
inTag = true;
continue;
}
if (!inTag) {
sb.append(c[i]);
}
}
//XXX, would be nicer to support the full complement of entities...
title = sb.toString().replace(" ", " "); //NOI18N
}
String completeTitle = MessageFormat.format(
NbBundle.getMessage(DefaultSeparateContainer.class, "CTL_SeparateEditorTitle"),
title);
setTitle(completeTitle);
}
示例7: setText
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public void setText(String text) {
// check for HTML
if (BasicHTML.isHTMLString(text)) setContentType("text/html");
super.setText(text);
}
示例8: AbstractToolIconNode
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
* Constructor.
*
* @param image image displayed on the icon
* @param text optional HTML or plain text, centered under image
*/
public AbstractToolIconNode( Image image, String text ) {
super();
PImage imageNode = new PImage( image );
imageNode.setOffset( 0, 0 );
addChild( imageNode );
if ( text != null ) {
PNode labelNode = null;
if ( BasicHTML.isHTMLString( text ) ) {
HTMLNode htmlNode = new HTMLNode( text );
htmlNode.setFont( LABEL_FONT );
htmlNode.setHTMLColor( LABEL_COLOR );
labelNode = htmlNode;
}
else {
PText ptextNode = new PText( text );
ptextNode.setFont( LABEL_FONT );
ptextNode.setTextPaint( LABEL_COLOR );
labelNode = ptextNode;
}
addChild( labelNode );
if ( imageNode.getWidth() > labelNode.getWidth() ) {
imageNode.setOffset( 0, 0 );
labelNode.setOffset( imageNode.getX() + ( imageNode.getWidth() - labelNode.getWidth() ) / 2, imageNode.getY() + imageNode.getHeight() + VERTICAL_SPACING );
}
else {
labelNode.setOffset( 0, imageNode.getY() + imageNode.getHeight() + VERTICAL_SPACING );
imageNode.setOffset( labelNode.getX() + ( labelNode.getWidth() - imageNode.getWidth() ) / 2, 0 );
}
}
}
示例9: getBeakerViewRatioString
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
public static final String getBeakerViewRatioString() {
String s = CHECK_BOX_H3O_OH_RATIO;
if ( !BasicHTML.isHTMLString( CHECK_BOX_H3O_OH_RATIO ) ) {
s = "<html>" + s + "</html>";
}
Object[] args = { LABEL_H3O, LABEL_OH };
return MessageFormat.format( s, args );
}
示例10: makeHTML
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
* Converts a plain text string to HTML.
* If the text string is already HTML, then it is simply returned.
*
* @param s
* @return HTML
*/
private String makeHTML( String s ) {
String htmlString = s;
if ( !BasicHTML.isHTMLString( s ) ) {
htmlString = "<html>" + s + "</html>";
}
return htmlString;
}
示例11: setErrorMessage
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
* Set the error message for the dialog box
*
* @param errorMessage Message for the error dialog
*/
private void setErrorMessage(String errorMessage) {
if (BasicHTML.isHTMLString(errorMessage)) {
this.errorMessage.setContentType("text/html");
} else {
this.errorMessage.setContentType("text/plain");
}
this.errorMessage.setText(errorMessage);
this.errorMessage.setCaretPosition(0);
}
示例12: configureMessagePaneUi
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
@NotNull
public static JTextPane configureMessagePaneUi(JTextPane messageComponent,
String message,
final boolean addBrowserHyperlinkListener) {
messageComponent.setFont(UIUtil.getLabelFont());
if (BasicHTML.isHTMLString(message)) {
final HTMLEditorKit editorKit = new HTMLEditorKit();
editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(UIUtil.getLabelFont(), UIUtil.getLabelForeground()));
messageComponent.setEditorKit(editorKit);
messageComponent.setContentType(UIUtil.HTML_MIME);
if (addBrowserHyperlinkListener) {
messageComponent.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
}
}
messageComponent.setText(message);
messageComponent.setEditable(false);
if (messageComponent.getCaret() != null) {
messageComponent.setCaretPosition(0);
}
if (UIUtil.isUnderNimbusLookAndFeel()) {
messageComponent.setOpaque(false);
messageComponent.setBackground(UIUtil.TRANSPARENT_COLOR);
}
else {
messageComponent.setBackground(UIUtil.getOptionPaneBackground());
}
messageComponent.setForeground(UIUtil.getLabelForeground());
return messageComponent;
}
示例13: createTextComponent
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
protected JComponent createTextComponent() {
JComponent textComponent;
if (BasicHTML.isHTMLString(myMessage)) {
textComponent = createMessageComponent(myMessage);
}
else {
JLabel textLabel = new JLabel(myMessage);
textLabel.setUI(new MultiLineLabelUI());
textComponent = textLabel;
}
textComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
return textComponent;
}
示例14: setText
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
public void setText(String text) {
if (BasicHTML.isHTMLString(getText())) { // if is currently showing string as html
super.setText(underlineTextInHtml(text));
}
else {
super.setText(text);
}
myOriginalText = text;
}
示例15: setErrorMessage
import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
* Set the error message for the dialog box
* @param errorMessage Message for the error dialog
*/
private void setErrorMessage(String errorMessage) {
if(BasicHTML.isHTMLString(errorMessage)) {
this.errorMessage.setContentType("text/html");
} else {
this.errorMessage.setContentType("text/plain");
}
this.errorMessage.setText(errorMessage);
this.errorMessage.setCaretPosition(0);
}