SWING组件学习7:滚动条的综合应用

import javax.swing.*;

/**
 * @author rice
 *
 * TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
public class Jscroll extends JFrame {
 JButton ok;

 JTextField text = new JTextField(15);

 JPasswordField pwd = new JPasswordField(15);

 JTextArea ta = new JTextArea(5, 15);

 JLabel username = new JLabel("用户名:");

 JLabel password = new JLabel("密  码:");

 JLabel area = new JLabel("正  文:");

 Jscroll() {
  super("提交表单");
  this.setSize(250, 300);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  JPanel p = new JPanel();
  ImageIcon img = new ImageIcon("G://eclipse-work//jswing//imgs//13.gif");
  ok = new JButton("确认", img);
  //密码符号
  pwd.setEchoChar('#');
  //  文本域自动换行。
  //ta.setLineWrap(true);
  JScrollPane scroll = new JScrollPane(ta,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  p.add(username);
  p.add(text);
  p.add(password);
  p.add(pwd);
  p.add(area);
  p.add(scroll);
  p.add(ok);
  this.setContentPane(p);

 }

 public static void main(String[] args) {
  Jscroll j = new Jscroll();
  j.show();
 }
}

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值