javax.swing.JTextPane.setForeground()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中javax.swing.JTextPane.setForeground()方法的一些代码示例,展示了JTextPane.setForeground()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.setForeground()方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:setForeground

JTextPane.setForeground介绍

暂无

代码示例

代码示例来源:origin: marytts/marytts

jTextPane_nextSentence.setEditable(false);
jTextPane_nextSentence.setFont(new java.awt.Font("Tahoma", 0, 24));
jTextPane_nextSentence.setForeground(new java.awt.Color(50, 50, 50));
jTextPane_nextSentence
    .setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");

代码示例来源:origin: marytts/marytts

jTextPane_nextSentence.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jTextPane_nextSentence.setFont(new java.awt.Font("Tahoma", 0, 24));
jTextPane_nextSentence.setForeground(new java.awt.Color(50, 50, 50));
jTextPane_nextSentence
    .setText("This is a long and boring test sentence, the only purpose of which is to see how to break between lines without making any difference across the windows.");

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

private void prepareMessage(final String msg, final ImageIcon icon, final Color fgColor) {
  if( !SwingUtilities.isEventDispatchThread() ) {
    SwingUtilities.invokeLater( new Runnable() {
      @Override
      public void run() {
        prepareMessage( msg, icon, fgColor );
      }
    } );
    return;
  }
  String message = msg;
  messagePane.setToolTipText (message);
  if (message != null) {
    message = message.replaceAll("\\s", " "); // NOI18N
    if (! message.toUpperCase().startsWith("<HTML>")) { // NOI18N
      message = "<HTML>" + message; // NOI18N
    }
  }
  iconLabel.setIcon(icon);
  iconLabel.setForeground(fgColor);
  messagePane.setForeground(fgColor);
  messagePane.setText(message);
  messagePane.setFocusable(message != null);
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

errorPanel.setBorder(BorderFactory.createEmptyBorder(0, 12, 12, 11));
messagePane = new FixedHeightPane ();
messagePane.setForeground (nbErrorForeground);
iconLabel = new FixedHeightLabel ();
errorPanel.add(iconLabel, BorderLayout.LINE_START);

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void setResource(final URI resource) {
  final URI lastResource = SwingSafePbeParametersView.lastResource;
  if (!lastResource.equals(resource)
      && !lastResource.equals(SwingSafePbeParametersView.INITIAL_RESOURCE)) {
    this.resource.setForeground(Color.RED);
  } else {
    this.resource.setForeground(defaultForeground);
  }
  this.resource.setText(resource.toString());
  SwingSafePbeParametersView.lastResource = resource;
}

代码示例来源:origin: net.java.truevfs/truevfs-key-swing

@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void setResource(final URI resource) {
  final URI lastResource = SwingSafePbeParametersView.lastResource;
  if (!lastResource.equals(resource)
      && !lastResource.equals(SwingSafePbeParametersView.INITIAL_RESOURCE)) {
    this.resource.setForeground(Color.RED);
  } else {
    this.resource.setForeground(defaultForeground);
  }
  this.resource.setText(resource.toString());
  SwingSafePbeParametersView.lastResource = resource;
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-driver-zip

@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void setResource(final URI resource) {
  final URI lastResource = SwingSafePbeParametersView.lastResource;
  if (!lastResource.equals(resource)
      && !lastResource.equals(SwingSafePbeParametersView.INITIAL_RESOURCE)) {
    this.resource.setForeground(Color.RED);
  } else {
    this.resource.setForeground(defaultForeground);
  }
  this.resource.setText(resource.toString());
  SwingSafePbeParametersView.lastResource = resource;
}

代码示例来源:origin: net.java.truevfs/truevfs-key-swing

@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void setResource(final URI resource) {
  final URI lastResource = SwingSafePbeParametersView.lastResource;
  if (!lastResource.equals(resource)
      && !lastResource.equals(SwingSafePbeParametersView.INITIAL_RESOURCE)) {
    this.resource.setForeground(Color.RED);
  } else {
    this.resource.setForeground(defaultForeground);
  }
  this.resource.setText(resource.toString());
  SwingSafePbeParametersView.lastResource = resource;
}

代码示例来源:origin: net.java.truecommons/truecommons-key-swing

@Override
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void setResource(final URI resource) {
  final @Nullable URI lastResource = view.getLastResource();
  if (null != lastResource && !resource.equals(lastResource)) {
    this.resource.setForeground(Color.RED);
  } else {
    this.resource.setForeground(defaultForeground);
  }
  this.resource.setText(resource.toString());
  view.setLastResource(resource);
}

代码示例来源:origin: net.java.truecommons/truecommons-key-swing

@Override
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
public void setResource(final URI resource) {
  final @Nullable URI lastResource = view.getLastResource();
  if (null != lastResource && !resource.equals(lastResource)) {
    this.resource.setForeground(Color.RED);
  } else {
    this.resource.setForeground(defaultForeground);
  }
  this.resource.setText(resource.toString());
  view.setLastResource(resource);
}

代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz

JTextPane createSimplePane() {
  JTextPane textPane = new JTextPane();
  textPane.setMargin(new Insets(1, 1, 1, 1));
  textPane.setBackground(Color.WHITE);
  textPane.setForeground(Color.BLACK);
  return textPane;
}

代码示例来源:origin: stackoverflow.com

public WarnaText(JTextPane source) throws BadLocationException
{
  source.setForeground(Color.BLACK);
  Matcher komen=Pattern.compile("(/\\*([^\\*]|(\\*(?!/))+)*+\\*+/)|(\\/\\/.+)").matcher(source.getText());
  while(komen.find())
  {
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, Color.RED);

    aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Concolas");

    source.select(komen.start(),komen.end());

    source.setCharacterAttributes(aset, false);
  }
}

代码示例来源:origin: gurkenlabs/litiengine

private static Component initConsole() {
 // TODO: implement possibility to configure the desired log level
 Logger root = Logger.getLogger("");
 JTextPane consoleTextArea = new JTextPane();
 JScrollPane consoleScrollPane = new JScrollPane();
 consoleScrollPane.setViewportBorder(null);
 consoleScrollPane.setViewportView(consoleTextArea);
 consoleTextArea.setEditable(false);
 consoleTextArea.setBackground(AssetPanel.BACKGROUND);
 consoleTextArea.setForeground(Color.WHITE);
 consoleTextArea.setAutoscrolls(true);
 root.addHandler(new ConsoleLogHandler(consoleTextArea));
 return consoleScrollPane;
}

代码示例来源:origin: zgqq/mah

private void decorateContent(SwingLayoutTheme layoutTheme) {
    String contentColor = layoutTheme.findProperty("text-foreground-color");
    String contentBackgroundColor = layoutTheme.findProperty("text-background-color");
    this.content.setForeground(Color.decode(contentColor));
    this.content.setBackground(Color.decode(contentBackgroundColor));
  }
}

代码示例来源:origin: zgqq/mah

private void decorateDescription(SwingLayoutTheme layoutTheme) {
  String descriptionColor = layoutTheme.findProperty("text-foreground-color");
  this.description.setForeground(Color.decode(descriptionColor));
  String descriptionBackgroundColor = layoutTheme.findProperty("text-background-color");
  this.description.setBackground(Color.decode(descriptionBackgroundColor));
}

代码示例来源:origin: aterai/java-swing-tips

@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  textPane.setFont(table.getFont());
  textPane.setText("\t" + Objects.toString(value, ""));
  if (isSelected) {
   textPane.setForeground(table.getSelectionForeground());
   panel.setBackground(table.getSelectionBackground());
  } else {
   textPane.setForeground(table.getForeground());
   panel.setBackground(table.getBackground());
  }
  panel.add(textPane, BorderLayout.EAST);
  return panel;
 }
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

private void disableHTML() {
  messageField.setContentType("text/plain");
  final Color color = getStyle().
      getBaseValues().getColor(TEXT_COLOR_KEY);
  messageField.setForeground(color);
  messageField.setOpaque(false);
  messageField.setEditable(false);
  messageField.setEditorKit(new StyledEditorKit());
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
  public void run() {
    if (textPane == null)
      return;
    Color foregr = textPane.getForeground();
    if ((foregr == null) || (foregr instanceof UIResource)) {
      textPane
          .setForeground(SubstanceColorUtilities
              .getForegroundColor(SubstanceLookAndFeel
                  .getCurrentSkin(textPane)
                  .getEnabledColorScheme(
                      SubstanceLookAndFeel
                          .getDecorationType(textPane))));
    }
  }
});

代码示例来源:origin: eu.mihosoft.vrl/vrl

@Override
public void contentChanged() {
  super.contentChanged();
  htmlCommit.setForeground(getStyle().
      getBaseValues().getColor(Canvas.TEXT_COLOR_KEY));
  versionList.setForeground(getStyle().
      getBaseValues().getColor(Canvas.TEXT_COLOR_KEY));
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

@Override
public void contentChanged() {
  super.contentChanged();
  htmlCommit.setForeground(getStyle().
      getBaseValues().getColor(Canvas.TEXT_COLOR_KEY));
  versionList.setForeground(getStyle().
      getBaseValues().getColor(Canvas.TEXT_COLOR_KEY));
}

相关文章

JTextPane类方法