Frame:文本域

package com.tai.test02;

import javax.swing.*;
import java.awt.*;
import java.util.Vector;

public class TestTextDemo01 extends JFrame {
    public TestTextDemo01() {

        Container container = getContentPane();

        //文本一行
        container.setLayout(new GridLayout(2,2));
        JTextField jTextField = new JTextField("hello");
        container.add(jTextField);

        //密码文本
        JPasswordField jPasswordField = new JPasswordField();
        jPasswordField.setEchoChar('*');
        container.add(jPasswordField);

        //文本域
        JTextArea jTextArea = new JTextArea(10,10);
        jTextArea.setText("123123");
        container.add(jTextArea);

        setVisible(true);
        setBounds(100,100,600,400);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestTextDemo01();
    }
}

你可能感兴趣的:(GUI)