【问题标题】:How to display the number of rows to the component side RSyntaxTextArea如何将行数显示到组件端RSyntaxTextArea
【发布时间】:2014-04-04 12:25:10
【问题描述】:

如何在组件旁边显示行数 -> RSyntaxTextArea

下面的代码有效,但我需要使用特定组件代替我的框架,当我这样做时,旁边的行会消失。

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.flp.entidades;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rtextarea.RTextScrollPane;

/**
 *
 * @author Filipe
 */
public class TextEditorRSyntax extends JFrame {

    public TextEditorRSyntax() {

        JPanel cp = new JPanel(new BorderLayout());

        RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
        textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
        textArea.setCodeFoldingEnabled(true);
        RTextScrollPane sp = new RTextScrollPane(textArea);
        cp.add(sp);

         Color azulClaro =  Color.decode("#E0EEEE");
        textArea.setCurrentLineHighlightColor(azulClaro);
        setContentPane(cp);
        setTitle("Text Editor Demo");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
        setLocationRelativeTo(null);

    }

    public static void main(String[] args) {
        // Start all Swing applications on the EDT.
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new TextEditorRSyntax().setVisible(true);
            }
        });
    }

}

【问题讨论】:

    标签: java rsyntaxtextarea


    【解决方案1】:

    小伙子,documentation 是你的朋友

    sp.setLineNumbersEnabled(true);
    

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2018-06-25
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 2021-07-08
      相关资源
      最近更新 更多