/* * JPanel 使用 */ package com.swing; import java.awt.GridLayout; import javax.swing.*; class jpanel extends JFrame{ JPanel jp1,jp2,jp3; JLabel jl1,jl2; JTextField jtf1; JPasswordField jpf1; JButton jb1,jb2,jb3,jb4,jb5; public static void main(String[] args){ jpanel ob_jpanel=new jpanel(); } public jpanel(){ this.setLayout(new GridLayout(3,1)); jp1=new JPanel(); jp2=new JPanel(); jp3=new JPanel(); //设置标签 jl1=new JLabel("用户名"); jl2=new JLabel("密码"); //设置文本框和密码框 jtf1=new JTextField(10); jpf1=new JPasswordField(10); //设置按钮 jb1=new JButton("登陆"); jb2=new JButton("取消"); jp1.add(jl1); jp1.add(jtf1); jp2.add(jl2); jp2.add(jpf1); jp3.add(jb1); jp3.add(jb2); this.add(jp1); this.add(jp2); this.add(jp3); this.setTitle("jpanel的使用"); this.setSize(300,150); this.setLocation(100,100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } }
Java JPanel的使用
原创
©著作权归作者所有:来自51CTO博客作者xiaohongyangok的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:Java 网格布局
下一篇:java 多选框与单选按钮的使用
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
熟悉博客园
可以可以嘻嘻11.5#include<bits/stdc++.h>using namespace std;int main(){ return 0;}
leetcode #include c++ -
hello!博客园
我打算在这里写关于算法和编程的博客!
博客园 编程 -
博客园背景
...
记录