卡片选项页面 JTabbedPane 的使用
2024-09-04 05:36:50
package first;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class TtpDemo extends JFrame
{
TtpDemo() {
// TODO Auto-generated constructor stub
super("卡片选项页面示例");
setSize(300,200);
setVisible(true);
JTabbedPane jtp=new JTabbedPane();///定义卡片选项面页
///定义三张图片
ImageIcon icon1=new ImageIcon("./image/1.jpg");
ImageIcon icon2=new ImageIcon("./image/2.jpg");
ImageIcon icon3=new ImageIcon("./image/4.jpg");
jtp.addTab("城市", icon1,new CitiesPanel(),"城市名称");
jtp.addTab("文学", icon2,new BookPanel(),"文学书目");
jtp.addTab("网站", icon3,new NetPanel(),"精选网址");
getContentPane().add(jtp);
validate();
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
///定义面板CitiesPanel
class CitiesPanel extends JPanel
{
public CitiesPanel() {
// TODO Auto-generated constructor stub
JButton b1 =new JButton("北京");
JButton b2=new JButton("上海");
JButton b3 =new JButton("深圳");
JButton b4=new JButton("厦门");
add(b1);
add(b2);
add(b3);
add(b4);
}
}
///定义面板BookPanel
class BookPanel extends JPanel
{
public BookPanel() {
// TODO Auto-generated constructor stub
JCheckBox cb1=new JCheckBox("西游记");
JCheckBox cb2=new JCheckBox("三国演义");
JCheckBox cb3=new JCheckBox("红楼梦");
add(cb1);
add(cb2);
add(cb3);
}
}
///定义面板NetPanel
class NetPanel extends JPanel
{
public NetPanel() {
// TODO Auto-generated constructor stub
JComboBox jcb=new JComboBox();
jcb.addItem("思维论坛");
jcb.addItem("百度搜索");
jcb.addItem("java爱好者");
add(jcb);
}
}
public class Test
{
public static void main(String[] args)
{
new TtpDemo();
}
}
最新文章
- [原创]MySQL RR隔离级别下begin或start transaction开启事务后的可重复读?
- js 表单验证方法二
- mac--又发现了一款mac快捷键神器
- 【转】VS2010中 C++创建DLL图解
- 【ACMER纷纷表示】女生应该找一个玩ACM的男生
- jquery通过ajax获取数据(优化、封装)
- lightoj 1007
- kvm安装及配置
- python 文件及文件夹操作
- Android-67-Tomcat启动出错:Server Tomcat v7.0 Server at localhost failed to start.
- Angular - 预加载 Angular 模块
- bat脚本+diskpart 脚本实现自动划分磁盘分区
- shiro缓存管理
- Codeforces 1009G Allowed Letters 最大流转最小割 sosdp
- font-family 中文字体列表
- MySQL的SQL语句
- Ubuntu 16.04下安装golang
- select * from v$reserved_words
- linux平台模拟生成CAN设备
- selenium page object模式