176day(2.1信息存储,文本输入代码)

《2018年4月4日》【连续176天】

标题:2.1信息存储,文本输入代码;

内容:
A.

1.大端法和小段法:

2.布尔代数:

B.

 

public class TextComponentFrame extends JFrame{
	public static final int TEXTAREA_ROWS = 8;
	public static final int TXRTAREA_COLUMNS =20;
	
	public TextComponentFrame()
	{
		JTextField textField =new JTextField();
		JPasswordField passwordField =new JPasswordField();
		
		JPanel northPanel =new JPanel();
		northPanel.setLayout(new GridLayout(2,2));  //网格布局
		northPanel.add(new JLabel("User name:",SwingConstants.RIGHT));//控件的对其方式为right
		northPanel.add(textField);
		northPanel.add(new JLabel("Password:",SwingConstants.RIGHT));
		northPanel.add(passwordField);
		
		add(northPanel,BorderLayout.NORTH);
		
		JTextArea textArea =new JTextArea(TEXTAREA_ROWS,TXRTAREA_COLUMNS);
		JScrollPane scrollPane =new JScrollPane(textArea);
		add(scrollPane, BorderLayout.CENTER);
		JPanel southPanel =new JPanel();
		JButton insertButton =new JButton("Insert");
		southPanel.add(insertButton);
		insertButton.addActionListener(event ->
				textArea.append("User name:" +textField.getText()+"Password: "
						+new String(passwordField.getPassword()) +"\n"));
		add(southPanel,BorderLayout.SOUTH);
		pack();
	}
	public static void main(String[] args)
	{
		EventQueue.invokeLater(() ->
		{
			JFrame frame =new TextComponentFrame();
			frame.setTitle("Text");
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			frame.setVisible(true);
		});
		
	}
}

效果:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值