首页 > 代码库 > Java Swing界面编程(18)---单行文本输入组件:JTextField
Java Swing界面编程(18)---单行文本输入组件:JTextField
以下的程序与上一例有一点区别,仔细对比不难发现其中的不同之处。
package com.beyole.util; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; public class test17 { public static void main(String[] args) { JFrame frame = new JFrame("Crystal"); JTextField nameField = new JTextField(30); JTextField location = new JTextField("beyole", 10); JLabel name = new JLabel("输入姓名"); JLabel locat = new JLabel("所属单位"); location.setEnabled(false); name.setBounds(10, 10, 100, 20); locat.setBounds(10, 40, 100, 20); nameField.setBounds(80, 10, 90, 20); location.setBounds(80, 40, 50, 20); frame.setLayout(null); frame.add(locat); frame.add(name); frame.add(location); frame.add(nameField); frame.setSize(300, 100); frame.setLocation(300, 200); frame.setVisible(true); } }
程序截图:
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。