其他分享
首页 > 其他分享> > 文本框,密码框,文本域

文本框,密码框,文本域

作者:互联网

package lesson06;

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

public class TestTextDemo01 extends JFrame {

    public TestTextDemo01() {
        Container container=this.getContentPane();
//        container.setLayout(null);
        JTextField textField = new JTextField("hello");
        JTextField textField2 = new JTextField("world",20);
        container.add(textField,BorderLayout.NORTH);
        container.add(textField2,BorderLayout.SOUTH);



        this.setVisible(true);
        this.setSize(500,350);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

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

package lesson06;

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

public class TestTextDemo03 extends JFrame {

    public TestTextDemo03() {
        Container container=this.getContentPane();
//        container.setLayout(null);
        JPasswordField passwordField = new JPasswordField();
        passwordField.setEchoChar('*');
        container.add(passwordField);


        this.setVisible(true);
        this.setSize(500,350);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

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

 

 


标签:container,文本框,密码,new,import,文本,passwordField,public,JTextField
来源: https://blog.csdn.net/bianboxian018323/article/details/119301347