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


Java JTextArea.setSelectedTextColor方法代碼示例

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


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

示例1: installUI

import javax.swing.JTextArea; //導入方法依賴的package包/類
@Override
public void installUI(JComponent c) {
    super.installUI(c);

    jta = (JTextArea) c;

    JTextArea editor = jta;

    UIDefaults uidefaults = XToolkit.getUIDefaults();

    String prefix = getPropertyPrefix();
    Font f = editor.getFont();
    if ((f == null) || (f instanceof UIResource)) {
        editor.setFont(uidefaults.getFont(prefix + ".font"));
    }

    Color bg = editor.getBackground();
    if ((bg == null) || (bg instanceof UIResource)) {
        editor.setBackground(uidefaults.getColor(prefix + ".background"));
    }

    Color fg = editor.getForeground();
    if ((fg == null) || (fg instanceof UIResource)) {
        editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
    }

    Color color = editor.getCaretColor();
    if ((color == null) || (color instanceof UIResource)) {
        editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
    }

    Color s = editor.getSelectionColor();
    if ((s == null) || (s instanceof UIResource)) {
        editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
    }

    Color sfg = editor.getSelectedTextColor();
    if ((sfg == null) || (sfg instanceof UIResource)) {
        editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
    }

    Color dfg = editor.getDisabledTextColor();
    if ((dfg == null) || (dfg instanceof UIResource)) {
        editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
    }

    Border b = new BevelBorder(false,SystemColor.controlDkShadow,SystemColor.controlLtHighlight);
    editor.setBorder(new BorderUIResource.CompoundBorderUIResource(
        b,new EmptyBorder(2, 2, 2, 2)));

    Insets margin = editor.getMargin();
    if (margin == null || margin instanceof UIResource) {
        editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:56,代碼來源:XTextAreaPeer.java

示例2: Console

import javax.swing.JTextArea; //導入方法依賴的package包/類
public Console() {
	console = new JTextArea();
	clearButton = new JButton("Clear");
	//exportButton = new JButton("Export");
	setPanelTitle(PANEL_TITLE);

	clearButton.addActionListener(new ClearListener());
	//exportButton.addActionListener(new ExportListener());
	
	JPanel buttonsPanel = new JPanel();
	buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
	buttonsPanel.add(clearButton);
	//buttonsPanel.add(exportButton);
	
	console.setFont(new Font(CONSOLE_STYLE, Font.PLAIN, FONT_SIZE));
	//console.setRows(NROWS);
	console.setEditable(false);
	JScrollPane sp = new JScrollPane(console);
	sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
	sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	console.setSelectedTextColor(Color.GRAY);
	console.setLineWrap(true);
	console.setWrapStyleWord(true);
	
	// Automatic down scrolling
	DefaultCaret caret = (DefaultCaret) getConsole().getCaret();
	caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
	
	setLayout(new BorderLayout());
	
	add(buttonsPanel, BorderLayout.SOUTH);
	add(sp);
	
	LineBorder lineBorderPanel = (LineBorder) BorderFactory.createLineBorder(PANEL_BORDER_COLOR);
	setBorder(BorderFactory.createTitledBorder(lineBorderPanel, getPanelTitle()));
}
 
開發者ID:tteguayco,項目名稱:JITRAX,代碼行數:37,代碼來源:Console.java


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