当前位置: 首页>>代码示例>>Java>>正文


Java JTextPane.setForeground方法代码示例

本文整理汇总了Java中javax.swing.JTextPane.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JTextPane.setForeground方法的具体用法?Java JTextPane.setForeground怎么用?Java JTextPane.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextPane的用法示例。


在下文中一共展示了JTextPane.setForeground方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTreeCellRendererComponent

import javax.swing.JTextPane; //导入方法依赖的package包/类
@Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {
    JTextPane pane = new JTextPane();
    if (sel) {
        pane.setBackground(bgSel);
        pane.setForeground(fgSel);
    } else {
        pane.setBackground(bgNonSel);
        pane.setForeground(fgNonSel);
    }
    AssertionTreeNode node = (AssertionTreeNode) value;
    pane.setText("");
    try {
        pane.getDocument().insertString(pane.getDocument().getLength(), node.getProperty() + " {", propertyStyle);
        pane.getDocument().insertString(pane.getDocument().getLength(),
                node.getDisplayNode().replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r"), valueStyle);
        pane.getDocument().insertString(pane.getDocument().getLength(), "}", propertyStyle);
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
    return pane;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:DefaultContextMenu.java

示例2: setConsoleColor

import javax.swing.JTextPane; //导入方法依赖的package包/类
public static void setConsoleColor(Console con, Color foreground, Color background)
{
	JTextPane pane = con.getComponent();
	pane.setBackground(background);
	pane.setForeground(foreground);
	pane.setCaretColor(foreground);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:8,代码来源:ConsoleStyle.java

示例3: init

import javax.swing.JTextPane; //导入方法依赖的package包/类
private void init() {
    txpText = new JTextPane();
    txpLines = new JTextPane();

    // needed for correct layouting
    Insets ins = txpLines.getInsets();
    txpLines.setMargin(new Insets(ins.top + 1, ins.left, ins.bottom, ins.right));

    textHighlighter = new BookmarkHighlighter();
    lineHighlighter = new BookmarkHighlighter();

    txpText.setHighlighter(textHighlighter);
    //txpText.setMinimumSize(new Dimension(100, 100));
    txpText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    txpText.setEditable(false);

    txpLines.setHighlighter(lineHighlighter);
    txpLines.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    txpLines.setBackground(Color.LIGHT_GRAY);
    txpLines.setEnabled(false);
    txpLines.setForeground(Color.BLACK);
    txpLines.addMouseListener(mouseInputListener);

    fm = txpText.getFontMetrics(txpText.getFont());

    JPanel pnlBookmarks = new JPanel();
    pnlBookmarks.setLayout(new BorderLayout());
    pnlBookmarks.add(txpText, BorderLayout.CENTER);

    JScrollPane jspBookmarks = new JScrollPane(pnlBookmarks);
    jspBookmarks.setRowHeaderView(txpLines);
    jspBookmarks.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jspBookmarks.getVerticalScrollBar().setUnitIncrement(15);

    this.setLayout(new BorderLayout());
    this.add(jspBookmarks, BorderLayout.CENTER);
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:38,代码来源:BookmarkableLogViewer.java

示例4: AcercaDe

import javax.swing.JTextPane; //导入方法依赖的package包/类
/**
 * Create the frame.
 */
public AcercaDe(JFrame principal) {
	setIconImage(Toolkit.getDefaultToolkit().getImage(AcercaDe.class.getResource("/biblioteca/images/book.png")));
	this.principal=principal;
	principal.setEnabled(false);
	
	setTitle("Acerca de Biblioteca 2017");
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	setBounds(100, 100, 332, 330);
	setLocationRelativeTo(null);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JTextPane txtpnHola = new JTextPane();
	txtpnHola.setForeground(Color.WHITE);
	txtpnHola.setEditable(false);
	txtpnHola.setBackground(Color.BLACK);
	txtpnHola.setText("Biblioteca 2017 \u00A9 Juan Delgado Salmer\u00F3n");
	txtpnHola.setBounds(10, 11, 311, 20);
	contentPane.add(txtpnHola);
	
	JTextPane txtpnVersinBuild = new JTextPane();
	txtpnVersinBuild.setForeground(Color.WHITE);
	txtpnVersinBuild.setEditable(false);
	txtpnVersinBuild.setText("Versi\u00F3n 1.1.0\r\nBuild 20170516-5000");
	txtpnVersinBuild.setBackground(Color.BLACK);
	txtpnVersinBuild.setBounds(10, 42, 311, 34);
	contentPane.add(txtpnVersinBuild);
	
	JTextPane txtpnCopyrightBiblioteca = new JTextPane();
	txtpnCopyrightBiblioteca.setForeground(Color.WHITE);
	txtpnCopyrightBiblioteca.setEditable(false);
	txtpnCopyrightBiblioteca.setText("Copyright 2017 Biblioteca 2017 creado por Juan Delgado Salmer\u00F3n. Todos los derechos reservados por JunDev.\r\nEsta aplicaci\u00F3n tiene open-source los primeros 24 d\u00EDas de su distribuci\u00F3n, despu\u00E9s de dicha fecha se cobrar\u00E1n 200\u20AC por ella.");
	txtpnCopyrightBiblioteca.setBackground(Color.BLACK);
	txtpnCopyrightBiblioteca.setBounds(10, 98, 311, 109);
	contentPane.add(txtpnCopyrightBiblioteca);
	
	JLabel lblImage = new JLabel("");
	lblImage.setIcon(new ImageIcon(AcercaDe.class.getResource("/biblioteca/images/jundev.png")));
	lblImage.setBounds(10, 214, 311, 79);
	contentPane.add(lblImage);
	
	JPanel panel = new JPanel();
	panel.setBackground(Color.BLACK);
	panel.setBounds(0, 0, 331, 304);
	contentPane.add(panel);
	
	setVisible(true);
	addWindowListener(this);
	setResizable(false);
}
 
开发者ID:JuandeLS3,项目名称:Library-app,代码行数:56,代码来源:AcercaDe.java

示例5: NotifyExcPanel

import javax.swing.JTextPane; //导入方法依赖的package包/类
/** Constructor.
*/
private NotifyExcPanel () {
    java.util.ResourceBundle bundle = org.openide.util.NbBundle.getBundle(NotifyExcPanel.class);
    next = new JButton ();
    Mnemonics.setLocalizedText(next, bundle.getString("CTL_NextException"));
    // bugfix 25684, don't set Previous/Next as default capable
    next.setDefaultCapable (false);
    previous = new JButton ();
    Mnemonics.setLocalizedText(previous, bundle.getString("CTL_PreviousException"));
    previous.setDefaultCapable (false);
    details = new JButton ();
    details.setDefaultCapable (false);

    output = new JTextPane() {
        public @Override boolean getScrollableTracksViewportWidth() {
            return false;
        }
    };
    output.setEditable(false);
    Font f = output.getFont();
    output.setFont(new Font("Monospaced", Font.PLAIN, null == f ? 12 : f.getSize() + 1)); // NOI18N
    output.setForeground(UIManager.getColor("Label.foreground")); // NOI18N
    output.setBackground(UIManager.getColor("Label.background")); // NOI18N

    setLayout( new BorderLayout() );
    add(new JScrollPane(output));
    setBorder( new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));
        
    next.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_NextException"));
    previous.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_PreviousException"));
    output.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_ExceptionStackTrace"));
    output.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_ExceptionStackTrace"));
    getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_NotifyExceptionPanel"));

    descriptor = new DialogDescriptor ("", ""); // NOI18N

    descriptor.setMessageType (DialogDescriptor.ERROR_MESSAGE);
    descriptor.setOptions (computeOptions(previous, next));
    descriptor.setAdditionalOptions (new Object[] {
                                         details
                                     });
    descriptor.setClosingOptions (new Object[0]);
    descriptor.setButtonListener (this);

    // bugfix #27176, create dialog in modal state if some other modal
    // dialog is opened at the time
    // #53328 do not let the error dialog to be created modal unless the main
    // window is visible. otherwise the error message may be hidden behind
    // the main window thus making the main window unusable
    descriptor.setModal( isModalDialogPresent() 
            && WindowManager.getDefault().getMainWindow().isVisible() );
    
    setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH + extraW, SIZE_PREFERRED_HEIGHT + extraH));

    dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    if( null != lastBounds ) {
        lastBounds.width = Math.max( lastBounds.width, SIZE_PREFERRED_WIDTH+extraW );
        dialog.setBounds( lastBounds );
    }
    
    dialog.getAccessibleContext().setAccessibleName(bundle.getString("ACN_NotifyExcPanel_Dialog")); // NOI18N
    dialog.getAccessibleContext().setAccessibleDescription(bundle.getString("ACD_NotifyExcPanel_Dialog")); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:65,代码来源:NotifyExcPanel.java

示例6: draw

import javax.swing.JTextPane; //导入方法依赖的package包/类
public void draw(Graphics g, GamePieceImage defn) {

    TextBoxItemInstance tbi = null;
    if (defn != null) {
      tbi = defn.getTextBoxInstance(getConfigureName());
    }
    if (tbi == null) {
      tbi = new TextBoxItemInstance();
    }

    Color fg = tbi.getFgColor().getColor();
    Color bg = tbi.getBgColor().getColor();

    Point origin = layout.getPosition(this);
    Rectangle r = new Rectangle(origin.x, origin.y, getWidth(), getHeight());
    String s = null;
    if (textSource.equals(SRC_FIXED)) {
      s = text;
    }
    else {
      if (defn != null) {
        if (tbi != null) {
          s = tbi.getValue();
        }
      }
    }

    Graphics2D g2d = ((Graphics2D) g);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, isAntialias() ?
      RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);

    AffineTransform saveXForm = null;
    if (getRotation() != 0) {
      saveXForm = g2d.getTransform();
      AffineTransform newXForm =
        AffineTransform.getRotateInstance(Math.toRadians(getRotation()), getLayout().getVisualizerWidth()/2, getLayout().getVisualizerHeight()/2);
      g2d.transform(newXForm);
    }

    if (bg != null) {
      g.setColor(bg);
      g.fillRect(r.x, r.y, r.width, r.height);
    }

    JTextPane l = new JTextPane();
    if (isHTML) l.setContentType("text/html"); //$NON-NLS-1$
    l.setText(s);
    l.setSize(width-2, height-2);
    l.setBackground(bg != null ? bg : new Color(0,true));
    l.setForeground(fg != null ? fg : new Color(0,true));
    FontStyle fs = FontManager.getFontManager().getFontStyle(fontStyleName);
    Font f = fs.getFont();
    l.setFont(f);

    final BufferedImage img = ImageUtils.createCompatibleTranslucentImage(
      Math.max(l.getWidth(), 1),
      Math.max(l.getHeight(), 1)
    );
    final Graphics2D big = img.createGraphics();
    l.paint(big);
    big.dispose();

    g2d.drawImage(img, origin.x+1, origin.y+1, null);

    if (saveXForm != null) {
      g2d.setTransform(saveXForm);
    }
  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:69,代码来源:TextBoxItem.java


注:本文中的javax.swing.JTextPane.setForeground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。