Java 类javax.swing.text.DefaultCaret 实例源码

项目:incubator-netbeans    文件:CaretUndoEdit.java   
@Override
protected void restoreLegacyCaret(Caret caret) {
    int markOffsetAndBias = this.markOffsetAndBias;
    if (markOffsetAndBias == COMPLEX_POSITIONS_MARKER) { // complex positions at time of undo edit creation
        markOffsetAndBias = extraOffsets[1];
    }
    int markOffset = getOffset(markOffsetAndBias);
    int dotOffset = getOffset(dotOffsetAndBias);
    if (caret instanceof DefaultCaret) {
        DefaultCaret dCaret = (DefaultCaret) caret;
        dCaret.setDot(markOffset, getBias(markOffsetAndBias));
        dCaret.moveDot(dotOffset, getBias(dotOffsetAndBias));
    } else {
        caret.setDot(markOffset);
        caret.moveDot(dotOffset);
    }
}
项目:green-cat    文件:TelemetryToolWindow.java   
private TelemetryToolWindow(Project project) {
    ToolWindowManager manager = ToolWindowManager.getInstance(project);

    if (window == null) {
        textPane = new JTextPane();
        textPane.setEditable(false);

        JBScrollPane scrollPane = new JBScrollPane(textPane);
        DefaultCaret caret = (DefaultCaret) textPane.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        textPane.setContentType("text/html");
        initHtmlComposer();

        window = manager.registerToolWindow(WINDOW_ID, scrollPane, ToolWindowAnchor.BOTTOM);
        window.show(EMPTY_TASK);
    }
}
项目:LeagueStats    文件:DebugFrame.java   
/**
 * Creates a new DebugFrame used for the logger to log its messages onto.
 */
public DebugFrame() {
    this.setUndecorated(true);
    this.setBackground(new Color(0, 0, 0, 0));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setSize(Display.WINDOW_WIDTH / 3, Display.WINDOW_HEIGHT);
    this.setLayout(new GridLayout(2, 5));
    this.setLocation(Display.WINDOW_POSITION);
    this.setResizable(false);

    this.textPane = new ColorableTextPane();
    this.textPane.setFont(new Font("Arial", Font.BOLD, 15));
    this.setPreferredSize(new Dimension(Display.WINDOW_WIDTH / 3, Display.WINDOW_HEIGHT));
    DefaultCaret caret = (DefaultCaret) this.textPane.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    final JScrollPane sp = new JScrollPane(this.textPane);
    sp.getViewport().setBackground(Color.GRAY);
    sp.getViewport().setFocusable(false);
    sp.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
    this.add(sp);

    this.setVisible(true);
}
项目:hearthstone    文件:PartidaView.java   
private PartidaView(Partida partida, boolean inicioTurno, GameCliente gameCliente) {
    PARTIDA = partida;
    this.gameCliente = gameCliente;
    initComponents();
    renderGraphics();
    this.inicioTurno = inicioTurno;
    DefaultCaret caret = (DefaultCaret) jTextAreaHistorico.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    hero = PARTIDA.getHero();
    oponente = PARTIDA.getOponente();
    adicionarPaineis();
    //configura os atalhos da janela atual
    inserirAtalhos();
    PARTIDA.setPartidaView(getInstance());
    PARTIDA.iniciarThreadExecutarJogadas();
    glassPane = (JPanel) getInstance().getGlassPane();
    glassPane.setLayout(new GridBagLayout());
    Arrays.asList(hero, oponente).forEach(Heroi::refreshDanoMagico);
}
项目:Universal-Pointer-Searcher    文件:UniversalPointerSearcherGUI.java   
private void considerSettingFoundPointersTextArea()
{
    List<MemoryPointer> memoryPointers = memoryPointerSearcher.getMemoryPointers();

    if (memoryPointers != null)
    {
        // Apply sorting
        MemoryPointerSorting memoryPointerSorting = sortingSelection.getItemAt(sortingSelection.getSelectedIndex());
        Comparator<MemoryPointer> comparator = memoryPointerSorting.getComparator();
        memoryPointers.sort(comparator);

        // Convert to String
        int index = offsetPrintingSettingSelection.getSelectedIndex();
        OffsetPrintingSetting offsetPrintingSetting = offsetPrintingSettingSelection.getItemAt(index);
        String foundPointersText = MemoryPointer.toString(memoryPointers, offsetPrintingSetting);

        // Disable the cursor position from changing when the text area is updated
        DefaultCaret caret = (DefaultCaret) foundPointersOutputArea.getCaret();
        caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

        foundPointersOutputArea.setText(foundPointersText);
    }
}
项目:workcraft    文件:ErrorWindow.java   
public ErrorWindow() {
    txtStdErr = new JTextArea();
    txtStdErr.setMargin(SizeHelper.getTextMargin());
    txtStdErr.setLineWrap(true);
    txtStdErr.setEditable(false);
    txtStdErr.setWrapStyleWord(true);
    txtStdErr.setForeground(Color.RED);
    txtStdErr.addMouseListener(new LogAreaMouseListener());

    DefaultCaret caret = (DefaultCaret) txtStdErr.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    JScrollPane scrollStdErr = new JScrollPane();
    scrollStdErr.setViewportView(txtStdErr);

    setLayout(new BorderLayout());
    add(scrollStdErr, BorderLayout.CENTER);
    addComponentListener(this);
}
项目:workcraft    文件:OutputWindow.java   
public OutputWindow() {
    txtStdOut = new JTextArea();
    txtStdOut.setMargin(SizeHelper.getTextMargin());
    txtStdOut.setLineWrap(true);
    txtStdOut.setEditable(false);
    txtStdOut.setWrapStyleWord(true);
    txtStdOut.addMouseListener(new LogAreaMouseListener());

    DefaultCaret caret = (DefaultCaret) txtStdOut.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    JScrollPane scrollStdOut = new JScrollPane();
    scrollStdOut.setViewportView(txtStdOut);

    setLayout(new BorderLayout());
    add(scrollStdOut, BorderLayout.CENTER);
}
项目:tmc-intellij    文件:OrganizationCard.java   
public OrganizationCard(Organization organization) {
    this.initComponents();

    this.organization = organization;

    DefaultCaret caret = (DefaultCaret) this.organizationInformation.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

    this.organizationName.setText(organization.getName());
    String information = organization.getInformation();
    if (information.length() > 75) {
        information = information.substring(0, 74) + "...";
    }
    this.organizationInformation.setText(information);
    this.organizationSlug.setText("/" + organization.getSlug());
    ImageIcon image = new ImageIcon("placeholderLogo.png");
    if (!organization.getLogoPath().contains("missing")) {
        image = new ImageIcon(logoUrl(organization.getLogoPath()));
    }
    image.setImage(image.getImage().getScaledInstance(49, 49, java.awt.Image.SCALE_SMOOTH));
    this.logo.setIcon(image);
}
项目:swing-material    文件:MaterialPasswordField.java   
/**
 * Creates a new password field.
 */
public MaterialPasswordField() {
    setBorder(null);
    setFont(getFont().deriveFont(16f)); //use default font, Roboto's bullet doesn't work on some platforms (i.e. Mac)
    floatingLabel.setText("");
    setOpaque(false);
    setBackground(MaterialColor.TRANSPARENT);

    setCaret(new DefaultCaret() {
        @Override
        protected synchronized void damage(Rectangle r) {
            MaterialPasswordField.this.repaint(); //fix caret not being removed completely
        }
    });
    getCaret().setBlinkRate(500);
}
项目:swing-material    文件:MaterialTextField.java   
/**
 * Default constructor for {@code MaterialTextField}. A default model is
 * created and the initial string is empty.
 */
public MaterialTextField() {
    super();
    setBorder(null);
    setFont(Roboto.REGULAR.deriveFont(16f));
    floatingLabel.setText("");
    setOpaque(false);
    setBackground(MaterialColor.TRANSPARENT);

    setCaret(new DefaultCaret() {
        @Override
        protected synchronized void damage(Rectangle r) {
            MaterialTextField.this.repaint(); //fix caret not being removed completely
        }
    });
    getCaret().setBlinkRate(500);
}
项目:thornsec    文件:BlockingFrame.java   
public BlockingFrame(OrgsecModel model) {
    this.model = model;
    JFrame frame = new JFrame("orgsec");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jtp = new JTabbedPane();

    JTextArea area = new JTextArea();
    out = new TextAreaOutputStream(area);
    JScrollPane areapane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    DefaultCaret caret = (DefaultCaret) area.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    areapane.setViewportView(area);
    jtp.add("blocking", areapane);

    frame.setContentPane(jtp);
    frame.setSize(400, 400);
    frame.setVisible(true);
}
项目:project-bianca    文件:PythonGUI.java   
/**
 * 
 */
@Override
public void init() {
    display.setLayout(new BorderLayout());
    display.setPreferredSize(new Dimension(800, 600));

    // --------- text menu begin ------------------------
    JPanel menuPanel = createMenuPanel();

    display.add(menuPanel, BorderLayout.PAGE_START);

    DefaultCaret caret = (DefaultCaret) pythonConsole.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    splitPane = createMainPane();

    display.add(splitPane, BorderLayout.CENTER);
    display.add(statusInfo, BorderLayout.PAGE_END);
}
项目:project-bianca    文件:JavaGUI.java   
/**
 * 
 */
@Override
public void init() {
    display.setLayout(new BorderLayout());
    display.setPreferredSize(new Dimension(800, 600));

    // --------- text menu begin ------------------------
    JPanel menuPanel = createMenuPanel();

    display.add(menuPanel, BorderLayout.PAGE_START);

    DefaultCaret caret = (DefaultCaret) pythonConsole.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    splitPane = createMainPane();

    display.add(splitPane, BorderLayout.CENTER);
    display.add(statusInfo, BorderLayout.PAGE_END);
}
项目:hyst    文件:HystFrame.java   
private JPanel makeOutputPanel()
{
    JPanel rv = new JPanel();

    rv.setLayout(new BorderLayout());

    outputArea.setLineWrap(false);
    outputArea.setEditable(false);
    DefaultCaret caret = (DefaultCaret) outputArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    // arg, this seems harder than it needs to be
    outputArea.setEnabled(false);
    Color trColor = outputArea.getBackground();
    outputArea.setEnabled(true);

    // setBackground doesn't seem to react to textResource colors
    Color color = new Color(trColor.getRed(), trColor.getGreen(), trColor.getBlue());
    outputArea.setBackground(color);

    JScrollPane sp = new JScrollPane(outputArea);

    rv.add(sp, BorderLayout.CENTER);

    return rv;
}
项目:MeteoInfoMap    文件:FrmTextEditor.java   
/**
 * Creates new form FrmTextEditor
 */
public FrmTextEditor() {
    initComponents();

    DefaultCaret caret = (DefaultCaret) this.jTextArea_Output.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    BufferedImage image = null;
    try {
        image = ImageIO.read(this.getClass().getResource("/org/meteoinfo/desktop/resources/snake.png"));
        this.setIconImage(image);
    } catch (Exception e) {
    }
    this.setScriptLanguage(_scriptLanguage);
    addNewTextEditor("New file");
    this._splitPanelSize = this.jSplitPane1.getBounds().getSize();
    this.setSize(600, 600);
    //this.jSplitPane1.setDividerLocation(0.6);
    this.jSplitPane1.setDividerLocation(5);
    //this.jScrollPane1.invalidate();
}
项目:ct-sim    文件:AndEverything.java   
/** 
 * Erstellt die Textarea, die das LCD des Bot zeigt 
 * @param d Display 
 */
public void buisitLcdViewer(Actuators.LcDisplay d) {
    JTextArea t = new JTextArea(d.getExternalModel(), null, d.getNumRows(), d.getNumCols());
    t.setEnabled(false);

    /*
     * Fix fuer Bug 8 im Trac ("Kein Scrollen moeglich wenn Sim aktiv").
     * Details hab ich nicht rausgekriegt, aber wenn man das Caret (=
     * Cursor) abschaltet geht's. Siehe Bug:
     * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4201999 und
     * zugehoerigen Fix:
     * http://java.sun.com/j2se/1.5.0/docs/guide/swing/1.5/#swingText
     */
    Misc.setCaretPolicy(t, DefaultCaret.NEVER_UPDATE);

    t.setFont(new Font("Monospaced", Font.PLAIN, 12));
    t.setDisabledTextColor(Color.BLACK);
    t.setBackground(new Color(170, 200, 90));
    t.setBorder(BorderFactory.createLoweredBevelBorder());
    t.setToolTipText(d.getName());
    t.setMaximumSize(t.getPreferredSize());
    t.setAlignmentX(Component.CENTER_ALIGNMENT);
    add(t);
    add(Box.createRigidArea(new Dimension(0, 5)));
}
项目:ingsw1-eftaios    文件:GUIFrame.java   
/** Create the text area and set some default properties
 *
 * @return The text area
 */
private JScrollPane createMessageArea() {
    mTextArea = new JTextArea( 5, 20 );
    mTextArea.setLineWrap(true);
    mTextArea.setWrapStyleWord(true);
    mTextArea.setEditable(false);
    mTextArea.setMargin( TEXT_AREA_PADDING );

    JScrollPane scrollPane = new JScrollPane(mTextArea); 
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    DefaultCaret caret = (DefaultCaret)mTextArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    scrollPane.setBorder( TEXT_AREA_MARGIN );

    return scrollPane;
}
项目:swingbox-javahelp-viewer    文件:BrowserPane.java   
/**
 * Initial settings
 */
protected void init()
{
    // "support for SSL"
    System.setProperty("java.protocol.handler.pkgs",
            "com.sun.net.ssl.internal.www.protocol");
    java.security.Security
            .addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    // Create custom EditorKit if needed
    if (swingBoxEditorKit == null) {
        swingBoxEditorKit = new SwingBoxEditorKit();
    }

    setEditable(false);
    setContentType("text/html");

    activateTooltip(true);

    Caret caret = getCaret();
    if (caret instanceof DefaultCaret)
        ((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
项目:Brino    文件:SouthPanel.java   
public SouthPanel() {
    // TODO Auto-generated constructor stub
    setLayout(new BorderLayout());
    add(LogPanel, BorderLayout.CENTER);
    LogPanel.setBackground(branco);
    DefaultCaret caret = (DefaultCaret) LOG.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    placaCom = new JLabel("Arduino Uno na COM1");
    setBackground(verde);
    placaCom.setForeground(branco);
    Font font = placaCom.getFont();
    // same font but bold
    Font boldFont = new Font(font.getFontName(), Font.ITALIC, font.getSize()-2);
    placaCom.setFont(boldFont);
    add(placaCom,BorderLayout.SOUTH);
}
项目:GHzClickerMAHProjekt    文件:ServerGUI.java   
/**
 * Constructor which builds up the whole GUI with sizes etc.
 * 
 * @param listener The ActionListener for the GUI
 */
public ServerGUI(ActionListener listener) {
    setPreferredSize(new Dimension(800, 850));
    setName("ServerGUI");
    setLayout(null);
    btnExit.setBounds(0, 750, 800, 62);
    add(sp);
    sp.setBounds(0, 0, 785, 750);
    add(btnExit);
    taLog.setFont(new Font("Arail", Font.BOLD, 12));
    DefaultCaret caret = (DefaultCaret) taLog.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    taLog.setEditable(false);

    btnExit.addActionListener(listener);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
}
项目:drone-slam    文件:ConsolePanel.java   
public ConsolePanel() {
        super(new GridBagLayout());

        checkBox = new JCheckBox("Redirect Console", false);
        checkBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                redirectSystemStreams(checkBox.isSelected());
            }
        });

        text = new JTextArea("Waiting for State ...");
//      text.setEditable(false);
        text.setFont(new Font("Courier", Font.PLAIN, 10));
        DefaultCaret caret = (DefaultCaret) text.getCaret(); // auto scroll
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        add(new JScrollPane(text), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        add(checkBox, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    }
项目:twitchplayclient    文件:TwitchPlays.java   
private JPanel createChatPanel(int x, int y, int width, int height)
{
    JPanel panel = new JPanel();
       panel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
       panel.setBounds(x, y, width, height);
       panel.setBackground(Color.BLACK);
       textarea = new JTextArea(10, 20);
       textarea.setMargin(new Insets(10, 10, 0, 0));
       textarea.setEditable(false);
       textarea.setBackground(Color.BLACK);
       textarea.setForeground(Color.WHITE);
       textarea.setFont(new Font("Courier", Font.BOLD, 14));
       JScrollPane scroll = new JScrollPane(textarea);
       scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
       DefaultCaret caret = (DefaultCaret)textarea.getCaret();
       caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
       panel.add(scroll);
       return panel;
}
项目:MediathekView    文件:DialogHilfe.java   
public DialogHilfe(JFrame parent, boolean modal, String text) {
    super(parent, modal);
    initComponents();
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    jTextArea1.setText(text);

    new EscBeenden(this) {
        @Override
        public void beenden_() {
            dispose();
        }
    };

    jButtonOk.addActionListener(e -> dispose());
    getRootPane().setDefaultButton(jButtonOk);
}
项目:gort-public    文件:AppDescriptionTopComponent.java   
public AppDescriptionTopComponent() {
    initComponents();
    setName(Bundle.CTL_AppDescriptionTopComponent());
    setToolTipText(Bundle.HINT_AppDescriptionTopComponent());

    descEditorPane = new JEditorPane();
    descEditorPane.setContentType(CONTENT_TYPE);

    // stop the text area from auto scrolling to bottom
    DefaultCaret caret = (DefaultCaret) descEditorPane.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

    // set the view port of the description to this editor pane
    descScrollPane.getViewport().add(descEditorPane);

    // Add a listener to this so that we can update the app description
    TopComponent.Registry reg = TopComponent.getRegistry();
    reg.addPropertyChangeListener(WeakListeners.propertyChange(this, reg));
}
项目:osrsclient    文件:ChatMainPane.java   
public void addChanPanel(String chanName) {

        JTextArea messagePanel = new JTextArea();
        messagePanel.setLineWrap(true);
        messagePanel.setBackground(new Color(71, 71, 71));
        messagePanel.setForeground(Color.white);
        messagePanel.setFont(ircFont);
        messagePanel.setEditable(false);
        DefaultCaret dc = (DefaultCaret) messagePanel.getCaret();
        dc.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        JTextArea userPanel = new JTextArea();
        userPanel.setBackground(new Color(71, 71, 71));

        messagePanels.put(chanName, messagePanel);
        userPanels.put(chanName, userPanel);

    }
项目:freeVM    文件:DefaultCaretChangeListenerTest.java   
public Result testSetVisible() {
    ChangeListenerImpl al1 = new ChangeListenerImpl(0);
    ChangeListenerImpl al2 = new ChangeListenerImpl(0);

    javax.swing.text.DefaultCaret dk = new javax.swing.text.DefaultCaret() {
    };

    dk.addChangeListener(al1);
    dk.addChangeListener(al2);
    dk.addChangeListener(al1);

    dk.setVisible(true);

    Util.waitQueueEventsProcess();

    List l1 = al1.getLog();
    List l2 = al2.getLog();

    if (l1.size() != 0 || l2.size() != 0) {
        return failed("wrong ChangeListener hooks called on dk.setVisible(true)");
    }

    return passed();
}
项目:ali-idea-plugin    文件:InsertHardBreakAction.java   
public void actionPerformed(ActionEvent event) {
    JEditorPane editor = getEditor(event);
    if (editor != null) {
        try {
            HTMLDocument doc = getHTMLDocument(editor);
            int offset = editor.getSelectionStart();
            Element paragraph = doc.getParagraphElement(offset);
            if (paragraph != null && "p-implied".equals(paragraph.getName())) {
                // when editing html without paragraphs, we have to take care of inserting hard beaks
                getHTMLEditorKit(editor).insertHTML(doc, offset, "<br>", 0, 0, HTML.Tag.BR);
                ((DefaultCaret)editor.getCaret()).setDot(editor.getSelectionEnd(), Position.Bias.Forward);
            } else {
                // when editing html with paragraphs, swing creates paragraphs for every break by itself
                new DefaultEditorKit.InsertBreakAction().actionPerformed(event);
            }
       } catch (Exception ex) {
            // not an html document
            new DefaultEditorKit.InsertBreakAction().actionPerformed(event);
        }
    }
}
项目:asciidoctor-intellij-plugin    文件:JeditorHtmlPanel.java   
public JeditorHtmlPanel(Document document) {
  jEditorPane = new JEditorPane();
  scrollPane = new JBScrollPane(jEditorPane);
  // Setup the editor pane for rendering HTML.
  File baseDir = new File("");
  VirtualFile parent = FileDocumentManager.getInstance().getFile(document).getParent();
  if (parent != null) {
    // parent will be null if we use Language Injection and Fragment Editor
    baseDir = new File(parent.getCanonicalPath());
  }
  final HTMLEditorKit kit = new AsciiDocEditorKit(baseDir);

  // Create an AsciiDoc style, based on the default stylesheet supplied by UiUtil.getHTMLEditorKit()
  // since it contains fix for incorrect styling of tooltips
  final String cssFile = isDarcula() ? "darcula.css" : "preview.css";
  final StyleSheet customStyle = loadStyleSheet(JeditorHtmlPanel.class.getResource(cssFile));
  final StyleSheet style = UIUtil.getHTMLEditorKit().getStyleSheet();
  style.addStyleSheet(customStyle);
  kit.setStyleSheet(style);

  //
  jEditorPane.setEditorKit(kit);
  jEditorPane.setEditable(false);
  // use this to prevent scrolling to the end of the pane on setText()
  ((DefaultCaret)jEditorPane.getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
项目:voipcall    文件:ConsoleTab.java   
public ConsoleTab(MainWindow main) {
    this.main = main;

    // area
    area = new JTextArea();
    Font font = Resources.FONT_CONSOLE;
    area.setFont(font);
    area.setEditable(false);
    DefaultCaret caret = (DefaultCaret) area.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    areaPane = new JScrollPane(area);

    // system output
    PrintStream windowStream = new PrintStream(new JTextAreaOutputStream(area));
    Util.setOutAndErr(windowStream);

    // config listener
    Config.addConfigListener(this);
    Config.notifyConfigListener(this);
}
项目:incubator-netbeans    文件:CaretUndoEdit.java   
protected void restoreLegacyCaret(Caret caret) {
    if (caret instanceof DefaultCaret) {
        ((DefaultCaret)caret).setDot(getOffset(dotOffsetAndBias), getBias(dotOffsetAndBias));
    } else {
        caret.setDot(getOffset(dotOffsetAndBias));
    }
}
项目:incubator-netbeans    文件:CommentsPanel.java   
private void setupTextPane(final JTextPane textPane, String comment) {
    if( UIUtils.isNimbus() ) {
        textPane.setUI( new BasicTextPaneUI() );
    }
    textPane.setText(comment);

    Caret caret = textPane.getCaret();
    if (caret instanceof DefaultCaret) {
        ((DefaultCaret)caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    // attachments
    if (!attachmentIds.isEmpty()) {
        AttachmentHyperlinkSupport.Attachement a = AttachmentHyperlinkSupport.findAttachment(comment, attachmentIds);
        if (a != null) {
            String attachmentId = a.id;
            if (attachmentId != null) {
                int index = attachmentIds.indexOf(attachmentId);
                if (index != -1) {
                    BugzillaIssue.Attachment attachment = attachments.get(index);
                    AttachmentLink attachmentLink = new AttachmentLink(attachment);
                    HyperlinkSupport.getInstance().registerLink(textPane, new int[] {a.idx1, a.idx2}, attachmentLink);
                } else {
                    Bugzilla.LOG.log(Level.WARNING, "couldn''t find attachment id in: {0}", comment); // NOI18N
                }
            }
        }
    }

    // pop-ups
    textPane.setComponentPopupMenu(commentsPopup);

    textPane.setBackground(blueBackground);

    textPane.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
    textPane.setEditable(false);
    textPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleName")); // NOI18N
    textPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CommentsPanel.class, "CommentsPanel.textPane.AccessibleContext.accessibleDescription")); // NOI18N
}
项目:incubator-netbeans    文件:ResultSetTableCellEditor.java   
public ResultSetTableCellEditor(final JTextField textField) {
    super(textField);
    delegate = new EditorDelegate() {

        @Override
        public void setValue(Object value) {
            val = value;
            textField.setText((value != null) ? value.toString() : "");
        }

        @Override
        public boolean isCellEditable(EventObject evt) {
            if (evt instanceof MouseEvent) {
                return ((MouseEvent) evt).getClickCount() >= 2;
            }
            return true;
        }

        @Override
        public Object getCellEditorValue() {
            String txtVal = textField.getText();
            if (val == null && txtVal.equals("")) {
                return null;
            } else {
                    return txtVal;
                }
            }
    };

    textField.addActionListener(delegate);
    // #204176 - workarround for MacOS L&F
    textField.setCaret(new DefaultCaret());
}
项目:ThingML-Tradfri    文件:LoggingPanel.java   
private void jCheckBoxLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxLogActionPerformed
    DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret();
    if (jCheckBoxLog.isSelected()) { 
       caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
       jTextArea1.setCaretPosition(jTextArea1.getDocument().getLength());
       jScrollPaneLog.setViewportView(jTextArea1);
    }
    else caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);

}
项目:MCPluginDebuggerforNetbeans    文件:DebugConsoleTopComponent.java   
public DebugConsoleTopComponent() {
    initComponents();
    ((DefaultCaret) outTextArea.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    setName(Bundle.CTL_DebugConsoleTopComponent());
    setToolTipText(Bundle.HINT_DebugConsoleTopComponent());
    processManager = new ServerProcessManager(config, line -> {
        if (line.equals("STX")) {
            outTextArea.setText("");
        } else {
            outTextArea.append(line + "\n");
        }
    });
}
项目:PTEAssistant    文件:Console.java   
public Console() {
    setLayout(new BorderLayout());
    setBorder(new TitledBorder("控制台"));
    textarea = new JTextArea();
    textarea.setCaretPosition(textarea.getText().length());
    textarea.setFont(new Font("新宋体", Font.PLAIN, 12));
    add(textarea);
    DefaultCaret caret = (DefaultCaret) textarea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    scrollPane = new JScrollPane();
    scrollPane.setViewportView(textarea);
    add(scrollPane, BorderLayout.CENTER);

    welcome();
}
项目:MCPluginDebuggerforIDEA    文件:DebugToolWindowFactory.java   
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    this.project = project;
    this.config = PluginDataConfig.getInstance(project);
    if (this.config != null) this.config.init(project);
    processManager = new ServerProcessManager(this.config, line -> {
        if (line.equals("STX")) outTextArea.setText("");
        else outTextArea.append(line + "\n");
    });
    ((DefaultCaret) outTextArea.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    Content content = ContentFactory.SERVICE.getInstance().createContent(mainPanel, "", false);
    toolWindow.getContentManager().addContent(content);
    setValues();
    setListeners();
}
项目:OpenJSharp    文件:SwingUtilities2.java   
/**
 * Sets the {@code SKIP_CLICK_COUNT} client property on the component
 * if it is an instance of {@code JTextComponent} with a
 * {@code DefaultCaret}. This property, used for text components acting
 * as editors in a table or tree, tells {@code DefaultCaret} how many
 * clicks to skip before starting selection.
 */
public static void setSkipClickCount(Component comp, int count) {
    if (comp instanceof JTextComponent
            && ((JTextComponent) comp).getCaret() instanceof DefaultCaret) {

        ((JTextComponent) comp).putClientProperty(SKIP_CLICK_COUNT, count);
    }
}
项目:code-sentinel    文件:MASConsoleColorGUI.java   
@Override
protected void initOutput() {
    output = new MASColorTextPane(Color.black);
    output.setEditable(false);
    ((DefaultCaret)output.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    if (isTabbed()) {
        tabPane.add(" all", new JScrollPane(output));
    } else {
        pcenter.add(BorderLayout.CENTER, new JScrollPane(output));
    }
}
项目:code-sentinel    文件:MASConsoleGUI.java   
protected void initOutput() {
    output = new JTextArea();
    output.setEditable(false);        
    ((DefaultCaret)output.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    if (isTabbed) {
        tabPane.add("common", new JScrollPane(output));
    } else {
        pcenter.add(BorderLayout.CENTER, new JScrollPane(output));
    }
}
项目:JITRAX    文件:Console.java   
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()));
}