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

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

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

JTextPane.repaint介绍

暂无

代码示例

代码示例来源:origin: apache/pdfbox

@Override
  public void actionPerformed(ActionEvent e)
  {
    isFiltering = filter.isSelected();
    StringBuilder buffer = new StringBuilder();
    stacktrace.setText(generateStackTrace(error, buffer).toString());
    stacktrace.setCaretPosition(0);
    stacktrace.repaint();
  }
});

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

private void forceCaretMoveToStart() {
//        if (text.getCaretPosition() < cmdStart) {
      // move caret first!
//        }
    text.repaint();
  }

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

public void mouseReleased(MouseEvent event) {
  if (event.isPopupTrigger()) {
    menu.show((Component)event.getSource(), event.getX(),
    event.getY());
  }
  text.repaint();
}

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

/**
 * Prints "\\n" (i.e. newline)
 */
public void println() {
  print("\n");
  text.repaint();
}

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

public void println(Object o) {
  print( String.valueOf(o) + "\n" );
  text.repaint();
}

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

for (int i = 0; i < 5; i++) {
  final JTextPane b = new JTextPane();
  b.setBorder(new JTextArea().getBorder());
  b.addFocusListener(new FocusListener() {

    @Override
    public void focusGained(FocusEvent arg0) {
      b.repaint();
    }

    @Override
    public void focusLost(FocusEvent arg0) {
      b.repaint();
    }

  });
  b.setText(Integer.toString(i));
  a.getContentPane().add(b);
}

代码示例来源:origin: protegeproject/protege

public void setLineWrap(boolean wrap) {
  editorKit.setLineWrap(wrap);
  text.revalidate();
  text.repaint();
}

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

/**
 * Sets the text pane.
 */
private void setTextPane() {
 Style defaultStyle = this.textPane.getStyle(defaultStyleName);
 // Style style = textPane.getStyle(typeName);
 // if (style == null || defaultStyle == null) {
 // System.out.println("Style is null.");
 // }
 Document doc = this.textPane.getDocument();
 try {
  doc.remove(0, doc.getLength());
  doc.insertString(doc.getLength(), "This is what an ", defaultStyle);
  doc.insertString(doc.getLength(), "annotation", this.currentStyle);
  doc.insertString(doc.getLength(), " of type ", defaultStyle);
  doc.insertString(doc.getLength(), this.currentTypeName, this.currentStyle);
  doc.insertString(doc.getLength(), " will look like.", defaultStyle);
 } catch (BadLocationException e) {
  // assert(false);
 }
 this.textPane.repaint();
}

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

public void println(Icon icon) {
  print(icon);
  println();
  text.repaint();
}

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

private void enter() {
  String s = getCmd();
  if ( s.length() == 0 )  // special hack for empty return!
    s = ";\n";
  else {
    history.add( s );
    s = s +"\n";
  }
  append("\n");
  histLine = 0;
  acceptLine( s );
  text.repaint();
}

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

private void showHistoryLine() {
  String showline;
  if ( histLine == 0 )
    showline = startedLine;
  else
    showline = history.get( history.size() - histLine );
  replaceRange( showline, cmdStart, textLength() );
  text.setCaretPosition(textLength());
  text.repaint();
}

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

private void forceCaretMoveToEnd() {
  if (text.getCaretPosition() < cmdStart) {
    // move caret first!
    text.setCaretPosition(textLength());
  }
  text.repaint();
}

代码示例来源:origin: senbox-org/snap-desktop

private void append(String text, AttributeSet attributes) {
    if (this.isVisible()) {
      int len = textArea.getDocument().getLength();
      textArea.setCaretPosition(len);
      textArea.setCharacterAttributes(attributes, false);
      textArea.replaceSelection("\n" + text);
      textArea.repaint();
    } else {
      buffer.append(text);
    }
  }
}

代码示例来源:origin: net.sourceforge.jadex/jadex-runtimetools-swing

public void run()
        {
          final Point pos = ((JViewport)details.getParent())
              .getViewPosition();
//                    System.out.println("Pos: " + pos);
          details.setText(report);
          details.repaint();
//                    details.setCaretPosition(0);
          ((JViewport)details.getParent()).setViewPosition(pos);

          // Hack!!! Reset position after freeing the event thread,
          //  something seems to destroy the position, grrr.
          SwingUtilities.invokeLater(new Runnable()
          {
            public void run()
            {
              ((JViewport)details.getParent()).setViewPosition(pos);
            }
          });

//                    JScrollPane    scroll    = (JScrollPane)details.getParent().getParent();
//                    int    h    = scroll.getHorizontalScrollBar().getValue();
//                    int    v    = scroll.getVerticalScrollBar().getValue();
//                    System.out.println("Pos: h="+h+", v="+v);
//                    details.setText(text.toString());
//                    details.setCaretPosition(0);
//                    scroll.getHorizontalScrollBar().setValue(h);
//                    scroll.getVerticalScrollBar().setValue(v);
        }
      });

代码示例来源:origin: org.activecomponents.jadex/jadex-runtimetools-swing

public void run()
        {
          final Point pos = ((JViewport)details.getParent())
              .getViewPosition();
//                    System.out.println("Pos: " + pos);
          details.setText(report);
          details.repaint();
//                    details.setCaretPosition(0);
          ((JViewport)details.getParent()).setViewPosition(pos);

          // Hack!!! Reset position after freeing the event thread,
          //  something seems to destroy the position, grrr.
          SwingUtilities.invokeLater(new Runnable()
          {
            public void run()
            {
              ((JViewport)details.getParent()).setViewPosition(pos);
            }
          });

//                    JScrollPane    scroll    = (JScrollPane)details.getParent().getParent();
//                    int    h    = scroll.getHorizontalScrollBar().getValue();
//                    int    v    = scroll.getVerticalScrollBar().getValue();
//                    System.out.println("Pos: h="+h+", v="+v);
//                    details.setText(text.toString());
//                    details.setCaretPosition(0);
//                    scroll.getHorizontalScrollBar().setValue(h);
//                    scroll.getVerticalScrollBar().setValue(v);
        }
      });

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public void setLineNumbersVisible(boolean newValue) {
  NumberedViewFactory viewFactory = (NumberedViewFactory) editor.getEditorKit().
      getViewFactory();
  boolean oldValue = viewFactory.isLineNumbersVisible();
  if (oldValue != newValue) {
    viewFactory.setLineNumbersVisible(newValue);
    prefs.putBoolean("lineNumbersVisible", newValue);
    firePropertyChange("lineNumbersVisible", oldValue, newValue);
    editor.revalidate();
    editor.repaint();
  }
}

代码示例来源:origin: blurpy/kouchat

/**
 * Focus the text field when the window is shown.
 *
 * {@inheritDoc}
 */
@Override
public void windowActivated(final WindowEvent e) {
  chatTP.repaint();
  mediator.activatedPrivChat(user);
  updateUserInformation();
  if (msgTF.isEnabled()) {
    msgTF.requestFocusInWindow();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

inbox.repaint();
} catch (IOException ex) {
  Exceptions.printStackTrace(ex);

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

text.repaint();
break;

代码示例来源:origin: net.imagej/imagej-ui-swing

protected void listIssues() {
  updateConflictList();
  panel.setText("");
  for (final Conflict conflict : conflictList) {
    maybeAddSeparator();
    newText(conflict.getSeverity().toString() + ": ", conflict.isError() ? red : normal);
    final String filename = conflict.getFilename();
    if (filename != null) addText(filename, bold);
    addText("\n" + conflict.getConflict());
    addText("\n");
    for (final Resolution resolution : conflict.getResolutions()) {
      addText("\n    ");
      addButton(resolution.getDescription(), new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
          resolution.resolve();
          listIssues();
        }
      });
    }
  }
  ok.setEnabled(!Conflicts.needsFeedback(conflictList));
  if (ok.isEnabled()) ok.requestFocus();
  if (isShowing()) {
    if (panel.getStyledDocument().getLength() == 0) addText(
      "No more issues to be resolved!", italic);
    panel.setCaretPosition(0);
    panel.repaint();
  }
}

相关文章

JTextPane类方法