javax.swing.JTextArea.setSelectionColor()方法的使用及代码示例

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

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

JTextArea.setSelectionColor介绍

暂无

代码示例

代码示例来源:origin: us.ihmc/ihmc-java-toolkit

public void appendMessage(String message, Color color)
{
 if (quiet)
   return;
 //    textArea.setForeground(color);
 //    textArea.setSelectedTextColor(color);
 textArea.setSelectionColor(color);
 //    textArea.append(message + "\n");
 if (message.length() > (WIDTH - 1 + 25))
   message = message + "\n";
 textArea.insert(message + "\n", 0);
}

代码示例来源:origin: us.ihmc/IHMCJavaToolkit

public void appendMessage(String message, Color color)
{
 if (quiet)
   return;
 //    textArea.setForeground(color);
 //    textArea.setSelectedTextColor(color);
 textArea.setSelectionColor(color);
 //    textArea.append(message + "\n");
 if (message.length() > (WIDTH - 1 + 25))
   message = message + "\n";
 textArea.insert(message + "\n", 0);
}

代码示例来源:origin: us.ihmc/simulation-construction-set-tools

public void appendMessage(String message, Color color)
  {
   if (QUIET)
     return;

//    textArea.setForeground(color);
//    textArea.setSelectedTextColor(color);
   textArea.setSelectionColor(color);

//    textArea.append(message + "\n");

   if (message.length() > (WIDTH - 1 + 25))
     message = message + "\n";

   textArea.insert(message + "\n", 0);
  }

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

private void setBackgroundColors() {
  preview.setBackground(themeData.getColor(ThemeData.EDITOR_BACKGROUND_COLOR));
  preview.setSelectionColor(themeData.getColor(ThemeData.EDITOR_SELECTED_BACKGROUND_COLOR));
}

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

public static void main(String[] args) {

  final JFrame frame = new JFrame("Selected Color Example");
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

  final JTextArea area = new JTextArea("Text for test...", 5, 10);
  frame.add(area, BorderLayout.CENTER);

  JButton button = new JButton("Select Color");
  button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      Color color = JColorChooser.showDialog(frame, "Colors",
          Color.BLUE);
      area.selectAll();
      // area.setSelectedTextColor(color); // color of selected text
      area.setSelectionColor(color); // background of selected text
      area.requestFocusInWindow();
    }
  });
  frame.add(button, BorderLayout.PAGE_END);

  frame.pack();
  frame.setVisible(true);

}

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

/**
 * Creates the panel in which the license text is displayed.
 * @return the panel in which the license text is displayed.
 */
private JScrollPane createLicensePanel() {
  JTextArea license;
  license = new JTextArea();
  license.setEditable(false);
  // Applies the file editor's theme to the license text.
  license.setForeground(ThemeManager.getCurrentColor(Theme.EDITOR_FOREGROUND_COLOR));
  license.setBackground(ThemeManager.getCurrentColor(Theme.EDITOR_BACKGROUND_COLOR));
  license.setSelectedTextColor(ThemeManager.getCurrentColor(Theme.EDITOR_SELECTED_FOREGROUND_COLOR));
  license.setSelectionColor(ThemeManager.getCurrentColor(Theme.EDITOR_SELECTED_BACKGROUND_COLOR));
  license.setFont(ThemeManager.getCurrentFont(Theme.EDITOR_FONT));
  license.setText(getLicenseText());
  // Sets the scroll policy and preferred dimensions.
  licensePanel = new JScrollPane(license, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  licensePanel.getViewport().setPreferredSize(new Dimension((int)license.getPreferredSize().getWidth(), 400));
  return licensePanel;
}

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

/**
 * Creates the dialog's shell output area.
 * @return a scroll pane containing the dialog's shell output area.
 */
private JScrollPane createOutputArea() {
  // Creates and initialises the output area.
  outputTextArea = new JTextArea();
  outputTextArea.setLineWrap(true);
  outputTextArea.setCaretPosition(0);
  outputTextArea.setRows(10);
  outputTextArea.setEditable(false);
  outputTextArea.addKeyListener(this);
  // Applies the current theme to the shell output area.
  outputTextArea.setForeground(ThemeManager.getCurrentColor(Theme.SHELL_FOREGROUND_COLOR));
  outputTextArea.setCaretColor(ThemeManager.getCurrentColor(Theme.SHELL_FOREGROUND_COLOR));
  outputTextArea.setBackground(ThemeManager.getCurrentColor(Theme.SHELL_BACKGROUND_COLOR));
  outputTextArea.setSelectedTextColor(ThemeManager.getCurrentColor(Theme.SHELL_SELECTED_FOREGROUND_COLOR));
  outputTextArea.setSelectionColor(ThemeManager.getCurrentColor(Theme.SHELL_SELECTED_BACKGROUND_COLOR));
  outputTextArea.setFont(ThemeManager.getCurrentFont(Theme.SHELL_FONT));
  // Creates a scroll pane on the shell output area.
  return new JScrollPane(outputTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}

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

private void setBackgroundColors() {
  shellPreview.setBackground(themeData.getColor(ThemeData.SHELL_BACKGROUND_COLOR));
  shellPreview.setSelectionColor(themeData.getColor(ThemeData.SHELL_SELECTED_BACKGROUND_COLOR));
  historyPreview.setBackground(themeData.getColor(ThemeData.SHELL_HISTORY_BACKGROUND_COLOR));
  historyPreview.setSelectionBackground(themeData.getColor(ThemeData.SHELL_HISTORY_SELECTED_BACKGROUND_COLOR));
}

代码示例来源:origin: org.apache.uima/uimaj-tools

/**
 * Creates the text area.
 */
private void createTextArea() {
 try {
  this.textArea = new JTextArea();
  this.addCursorOwningComponent(this.textArea);
  Border emptyBorder = BorderFactory.createEmptyBorder(2, 4, 2, 2);
  Border grayLineBordre = BorderFactory.createLineBorder(Color.gray, 1);
  this.textArea.setBorder(BorderFactory.createCompoundBorder(grayLineBordre, emptyBorder));
  this.textArea.setSelectionColor(selectionColor);
  this.textArea.setEditable(true);
  this.textArea.setLineWrap(true);
  this.textArea.setWrapStyleWord(true);
  this.textArea.setText(defaultText);
  this.textArea.addMouseListener(new PopupListener(this));
  // textArea.setFocusable(true);
  this.textArea.addFocusListener(new TextFocusHandler(this));
  this.textArea.getDocument().addDocumentListener(new TextChangedListener(this));
  this.textArea.addCaretListener(new CaretChangeHandler(this));
  this.undoMgr = new UndoMgr(this);
  this.textArea.getDocument().addUndoableEditListener(this.undoMgr);
 } catch (Exception e) {
  handleException(e);
 }
}

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

/**
 * Receives theme color changes notifications.
 */
public void colorChanged(ColorChangedEvent event) {
  switch(event.getColorId()) {
  case Theme.EDITOR_FOREGROUND_COLOR:
    textArea.setForeground(event.getColor());
    break;
  case Theme.EDITOR_BACKGROUND_COLOR:
    textArea.setBackground(event.getColor());
    break;
  case Theme.EDITOR_SELECTED_FOREGROUND_COLOR:
    textArea.setSelectedTextColor(event.getColor());
    break;
  case Theme.EDITOR_SELECTED_BACKGROUND_COLOR:
    textArea.setSelectionColor(event.getColor());
    break;
  }
}

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

textArea.setBackground(ThemeManager.getCurrentColor(Theme.EDITOR_BACKGROUND_COLOR));
textArea.setSelectedTextColor(ThemeManager.getCurrentColor(Theme.EDITOR_SELECTED_FOREGROUND_COLOR));
textArea.setSelectionColor(ThemeManager.getCurrentColor(Theme.EDITOR_SELECTED_BACKGROUND_COLOR));
textArea.setFont(ThemeManager.getCurrentFont(Theme.EDITOR_FONT));

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

jtpSource.setSelectionColor(new Color(255, 192, 192));
jtpSource.setMargin(new Insets(4, 4, 4, 4));
jtpSource.getDocument().addDocumentListener(this);

相关文章

JTextArea类方法