关于一个查询的JAVA界面,希望对你有启发
package work2; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.WindowConstants; class MyJframe extends JFrame{ JPanel Panel; JLabel ID,Name,Price,Birth; JTextField J1; JTextArea J2,J3,J4; JButton button1,button2; public MyJframe (){ setLayout(new BorderLayout()); init(); setTitle("查询窗口"); setBounds(700,400,600,350); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public void init(){ Panel=new JPanel(); Panel.setLayout(null);//把面板布局设置为空 //商品编号及文本框 ID=new JLabel("商品编号:"); ID.setBounds(120,30,150,50); J1=new JTextField(16); J1.setBounds(200, 45, 250, 20); Panel.add(ID); Panel.add(J1); //查询按钮 button1=new JButton("查询"); button1.setBounds(130,80,90,20); Panel.add(button1); //清除按钮 button2=new JButton("清除界面字符"); button2.setBounds(320,80,120,20); Panel.add(button2); //添加商品名称 Name=new JLabel("商品名称:"); Name.setBounds(120,115,120,30); J2=new JTextArea(); J2.setBounds(200,120,250,20); Panel.add(Name); Panel.add(J2); //添加价格信息 Price=new JLabel("价 格:"); Price.setBounds(120,156,120,30); J3=new JTextArea(); J3.setBounds(200,160,250,20); Panel.add(Price); Panel.add(J3); //添加出厂日期 Birth=new JLabel("出厂日期:"); Birth.setBounds(120,192,120,30); J4=new JTextArea(); J4.setBounds(200,195,250,20); Panel.add(Birth); Panel.add(J4); add(Panel); } } public class Interface{ public static void main(String[] args){ new MyJframe(); } }
所得界面:
本文来自博客园,作者:帅气的涛啊,转载请注明原文链接:https://www.cnblogs.com/handsometaoa/p/11937714.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)