Java开发编辑器语法高亮_RSyntaxTextArea 一个支持语法高亮,代码折叠编辑器Java Swing组件...

RSyntaxTextArea

68747470733a2f2f7472617669732d63692e6f72672f626f6262796c696768742f5253796e74617854657874417265612e7376673f6272616e63683d6d617374657268747470733a2f2f636f766572616c6c732e696f2f7265706f732f626f6262796c696768742f5253796e74617854657874417265612f62616467652e737667

RSyntaxTextArea is a customizable, syntax highlighting text component for Java Swing applications. Out of the box, it supports syntax highlighting for 40+ programming languages, code folding, search and replace, and has add-on libraries for code completion and spell checking. Syntax highlighting for additional languages can be added via tools such as JFlex.

RSyntaxTextArea is available under a BSD 3-Clause license. For more information, visit http://bobbylight.github.io/RSyntaxTextArea/.

Available in the Maven Central repository (com.fifesoft:rsyntaxtextarea:XXX). SNAPSHOT builds of the in-development, unreleased version are hosted on Sonatype.

Building

RSyntaxTextArea uses Gradle to build. To compile, run all unit tests, and create the jar, run:

./gradlew build --warning-mode all

RSTA 3.0 and newer requires Java 8 to compile and run. If you need Java 6 compatibility, you'll need to use a 2.6.x version.

Example Usage

RSyntaxTextArea is simply a subclass of JTextComponent, so it can be dropped into any Swing application with ease.

import javax.swing.*;

import java.awt.BorderLayout;

import org.fife.ui.rtextarea.*;

import org.fife.ui.rsyntaxtextarea.*;

public class TextEditorDemo extends JFrame {

public TextEditorDemo() {

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

RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);

textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);

textArea.setCodeFoldingEnabled(true);

RTextScrollPane sp = new RTextScrollPane(textArea);

cp.add(sp);

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 TextEditorDemo().setVisible(true);

});

}

}

Sister Projects

RSyntaxTextArea provides syntax highlighting, code folding, and many other features out-of-the-box, but when building a code editor you often want to go further. Below is a list of small add-on libraries that add more complex functionality:

AutoComplete - Adds code completion to RSyntaxTextArea (or any other JTextComponent).

RSTALanguageSupport - Code completion for RSTA for the following languages: Java, JavaScript, HTML, PHP, JSP, Perl, C, Unix Shell. Built on both RSTA and AutoComplete.

SpellChecker - Adds squiggle-underline spell checking to RSyntaxTextArea.

RSTAUI - Common dialogs needed by text editing applications: Find, Replace, Go to Line, File Properties.

Getting Help

Add an issue on GitHub

Check the project's home page

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java应用程序编写完成后,会通过Java编译器将源代码转换为字节码文件,其文件扩展名为.class。这些字节码文件包含了Java虚拟机可以理解和执行的指令集合。 字节码文件是一种中间文件,它与平台无关,可以在任何支持Java虚拟机的系统中运行。Java虚拟机会将字节码文件加载到内存中,逐行解释执行其中的指令。 通过将Java程序编译为字节码文件,可以实现Java的跨平台特性。无论是在Windows、Linux还是Mac等不同的操作系统上,只要有Java虚拟机,就可以运行相同的字节码文件。 扩展名为.class的文件一般不需要手动编辑,因为它是编译后的程序文件,包含机器可读的字节码指令,无法直观地进行修改。要对Java程序进行修改或改进,需要先修改源代码,然后重新编译生成新的.class文件。 在编写好的Java应用程序中,可以通过编辑器来查看和编辑源代码文件。常见的Java编辑器有Eclipse、IntelliJ IDEA和Visual Studio Code等。这些编辑器提供了代码高亮语法检查、代码提示等功能,方便开发人员编写、调试和维护Java程序。 总之,扩展名为.class的文件是通过Java编译器将Java应用程序源代码编译生成的字节码文件,它可以在任何支持Java虚拟机的系统中运行,实现了Java的跨平台特性。编辑器则是用来编写、编辑和维护Java程序源代码的工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值