zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然JAVA图形界面编程学习笔记:文本组件JTextComponent

    import java.awt.GridLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JPasswordField ;
    import javax.swing.JLabel ;
    public class JPasswordDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ;
            JPasswordField jpf1 = new JPasswordField() ;
            JPasswordField jpf2 = new JPasswordField() ;
            jpf2.setEchoChar('#') ;    // 设置回显
            JLabel lab1 = new JLabel("默认的回显:") ;
            JLabel lab2 = new JLabel("回显设置“#”:") ;
    
            lab1.setBounds(10,10,100,20) ;
            lab2.setBounds(10,40,100,20) ;
            jpf1.setBounds(110,10,80,20) ;
            jpf2.setBounds(110,40,50,20) ;
    
            frame.setLayout(null) ;
            frame.add(lab1) ;
            frame.add(jpf1) ;
            frame.add(lab2) ;
            frame.add(jpf2) ;
            frame.setSize(300,100) ;
            frame.setLocation(300,200) ;
            frame.setVisible(true) ;
        }
    };
    import java.awt.GridLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JTextArea ;
    import javax.swing.JLabel ;
    public class JTextAreaDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ;
            JTextArea jta = new JTextArea(3,10) ;    // 设置大小
            JLabel lab = new JLabel("多行文本域:") ;
            lab.setBounds(10,10,120,20) ; 
            jta.setBounds(130,10,150,100) ; 
            frame.setLayout(null) ;    // 取消布局管理器
            frame.add(lab) ;
            frame.add(jta) ;
            frame.setSize(300,150) ;
            frame.setLocation(300,200) ;
            frame.setVisible(true) ;
        }
    };
    import java.awt.GridLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JTextArea ;
    import javax.swing.JScrollPane ;
    import javax.swing.JLabel ;
    public class JTextAreaDemo02{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ;
            JTextArea jta = new JTextArea(3,10) ;    // 设置大小
            JLabel lab = new JLabel("多行文本域:") ;
            JScrollPane scr = new JScrollPane(jta,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS ) ;
            frame.setLayout(new GridLayout(2,1)) ;    // 取消布局管理器
            frame.add(lab) ;
            frame.add(scr) ;
            frame.setSize(300,150) ;
            frame.setLocation(300,200) ;
            frame.setVisible(true) ;
        }
    };
    import java.awt.GridLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JTextField ;
    import javax.swing.JLabel ;
    public class JTextDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ;
            JTextField name = new JTextField(30) ;
            JTextField noed = new JTextField("MLDN",10) ;
            JLabel nameLab = new JLabel("输入用户姓名:") ;
            JLabel noedLab = new JLabel("不可编辑文本:") ;
            name.setColumns(30) ;
            noed.setColumns(10) ;
            noed.setEnabled(false) ;    // 表示不可编辑
            frame.setLayout(new GridLayout(2,2)) ;
            frame.add(nameLab) ;
            frame.add(name) ;
            frame.add(noedLab) ;
            frame.add(noed) ;
            frame.setSize(300,100) ;
            frame.setLocation(300,200) ;
            frame.setVisible(true) ;
        }
    };
    import java.awt.GridLayout ;
    import javax.swing.JFrame ;
    import javax.swing.JTextField ;
    import javax.swing.JLabel ;
    public class JTextDemo02{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ;
            JTextField name = new JTextField(30) ;
            JTextField noed = new JTextField("MLDN",10) ;
            JLabel nameLab = new JLabel("输入用户姓名:") ;
            JLabel noedLab = new JLabel("不可编辑文本:") ;
            name.setColumns(30) ;
            noed.setColumns(10) ;
            noed.setEnabled(false) ;    // 表示不可编辑
    
            nameLab.setBounds(10,10,100,20) ;
            noedLab.setBounds(10,40,100,20) ;
            name.setBounds(110,10,80,20) ;
            noed.setBounds(110,40,50,20) ;
    
            frame.setLayout(null) ;
            frame.add(nameLab) ;
            frame.add(name) ;
            frame.add(noedLab) ;
            frame.add(noed) ;
            frame.setSize(300,100) ;
            frame.setLocation(300,200) ;
            frame.setVisible(true) ;
        }
    };
  • 相关阅读:
    点击单元格(LinkToAction)获取Table行号和数据(Table篇一)
    金额和数量不显示0
    自定event事件之全局初始化中自动触发(二)
    自定event事件之手动触发(一)
    Python的requests如何同时post图片二进制流和json数据application/octet-stream
    树莓派点亮LED灯需要几行代码?3行。小孩子都能学会
    50元求解pyqt加载并显示pdf问题
    pyqt5加载pdf文档失败
    建个群,互相关心
    唉,十年前的沙雕照片
  • 原文地址:https://www.cnblogs.com/tszr/p/12398848.html
Copyright © 2011-2022 走看看