GUI编程核心技术Swing——文本框,密码框

GUI编程核心技术Swing——文本框,密码框

文本框

package com.wei.lesson13;

import com.wei.lesson12.TestComboboxDemo02;

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

public class TestTextDome01 extends JFrame {
    
    
    public TestTextDome01(){
    
    
        Container container = this.getContentPane();

        JTextField textField = new JTextField("hello");
        JTextField textField1 = new JTextField("world");

        container.add(textField,BorderLayout.NORTH);
        container.add(textField1,BorderLayout.SOUTH);
        
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.setSize(500,350);

    }

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

    }
}

在这里插入图片描述

密码框

package com.wei.lesson13;

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

public class TestTextDome02 extends JFrame {
    
    
    public TestTextDome02(){
    
    
        Container container = this.getContentPane();

        JPasswordField passwordField = new JPasswordField();
        passwordField.setEchoChar('*');

        container.add(passwordField);

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

    }

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

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/wpc2018/article/details/108190067