java Swing 文本框的使用

/**
 * Java Swing 文本框控件
 * @author gao 
 */
package com.gao;

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

public class JTextFileldDemo extends JFrame{
	public JTextFileldDemo(){
		this.setTitle("文本框使用");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setBounds(100, 100, 250, 200);
		JPanel contentPane=new JPanel();
		contentPane.setBorder(new EmptyBorder(5,5,5,5));
		this.setContentPane(contentPane);
		contentPane.setLayout(new GridLayout(3,1,5,5));
		JPanel pane1=new JPanel();
		contentPane.add(pane1);
		JPanel pane2=new JPanel();
		contentPane.add(pane2);
		JPanel pane3=new JPanel();
		contentPane.add(pane3);
		JLabel label1=new JLabel("姓名:");
		
		JTextField textField1=new JTextField();
		textField1.setColumns(10);
		pane1.add(label1);
		pane1.add(textField1);
		JLabel label2=new JLabel("年龄:");
		JTextField textField2=new JTextField();
		textField2.setColumns(10);
		pane2.add(label2);
		pane2.add(textField2);
		JLabel label3=new JLabel("住址:");
		JTextField textField3=new JTextField();
		textField3.setColumns(10);
		pane3.add(label3);
		pane3.add(textField3);
		this.setVisible(true);
	}
    public static void main(String[]args){
    	JTextFileldDemo example=new JTextFileldDemo();
    }
}

swing,java,文本框0 

 文章来源:http://www.itnose.net/detail/6033886.html

更多文章:http://www.itnose.net/type/1.html

你可能感兴趣的:(java,swing)