java - 如何设置列的Jtable名称
问题描述
我有这段代码
String [] titles = {"حذف", "شماره درس","گروه","واحد","نام","تعداد ثبت نامی","نام استاد","زمان امتحان","زمان کلاس","وضعیت پیشنیازی ها","محدودیت"};
String[][] value = new String[1][11];
JTable table = new JTable(value, titles);
table.setBounds(800,450,1100,80);
table.setBorder(BorderFactory.createLineBorder(Color.black, 2, true));
table.setRowHeight(40);
table.setForeground(Color.BLACK);
table.setBackground(Color.lightGray);
mainPanel.add(table);
我怎样才能解决这个问题?
解决方案
mainPanel.add(table);
仅当您将表格添加到滚动窗格时,表格标题才会自动显示。
代码应该是:
//mainPanel.add(table);
JScrollPane scrollPane = new JScrollPane( table );
mainPanel.add( scrollPane );
推荐阅读
- oracle - Cloudformation AWS:将 RDS 连接到子网
- javascript - Webpack vue.js中如何将外部js集成到main.js文件中?
- mongodb - mongodb $lookup 3 级嵌套文档
- php - Google Translate API - html 文档翻译
- python - 玩家滑行和平台无法正确移动(Python/Pygame)
- c# - 我创建项目后,Android 应用程序不会立即编译
- python - wxPython - 更改网格对象的格式和外观
- php - 当我连接到 WIFI 时获取当前时间返回正常,如果我连接到 LTE,api 响应时间会出错
- scons - 使用 SCONS 构建多个目标
- go - 记录响应主体以用于日志记录