⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jtextareademo.java

📁 ssd3的教程 是我们老师给我们的 纯英文 有兴趣的可以
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;

/**
 * Demonstrates the component {@link JTextArea}. This class extends
 * class {@link @JPanel}.
 *
 * @author author name
 * @version 1.0.0
 */
public class JTextAreaDemo extends JPanel {

    private JTextArea textAreaOne;
    private JTextArea textAreaTwo;

    /**
     * Creates a window.
     *
     * @param args  not used.
     */
    public static void main(String[] args) {

        JFrame frame = new JFrame("JTextAreaDemo");

        frame.setContentPane(new JTextAreaDemo());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();    // Adjust the size of the window
        frame.setVisible(true);
    }

    /**
     * Creates two {@link JTextArea} components.
     */
    public JTextAreaDemo() {

        setBackground(Color.white);

        String text = "Line1\nLine2\nLine3\nLine4\nLine5\n"
                      + "Line6\nLine7\nLine8\nLine9\nLine10\n";

        // Create the components
        textAreaOne = new JTextArea(text, 7, 10);
        textAreaTwo = new JTextArea(text, 7, 10);

        // Change the colors of the components
        textAreaOne.setBackground(new Color(0, 0, 150));
        textAreaTwo.setBackground(new Color(0, 150, 0));
        textAreaOne.setForeground(Color.white);
        textAreaTwo.setForeground(Color.white);

        // Make the text area un-editable
        textAreaTwo.setEditable(false);

        // Add text area components to the scrollbar container.
        add(new JScrollPane(textAreaOne,
                             JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                             JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
        add(new JScrollPane(textAreaTwo,
                             JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                             JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -