java - 为什么我的 jTable 的 setBounds 不起作用
问题描述
我正在尝试使用 table.setBound 但我认为它不起作用。
这是代码。
public GUI() {
this.setSize(800, 400);
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("GUI");
JPanel panel = new JPanel();
this.add(panel);
String[] col = { "Name", "grade" };
Object[][] cells = {{ "A", "B" }, { "C", "D" }, { "E", "F" }};
JTable table = new JTable(cells, col);
table.setBounds(0, 0, 600, 100);
panel.add(new JScrollPane(table));
this.setVisible(true);
}
这是输出
解决方案
推荐阅读
- java-8 - 如何删除包含在特定字符串之后开始并以在java文件中找到的字符结尾的字符的行?
- java - 如何在全屏窗口上方放置 jframe?
- java - 如何在 Spring Batch Junit 测试中模拟 writer?
- python - 如何使用 openpyxl 添加新行而不删除以前的行?
- python - 检查类型是否为字典
- angular - 根据 angularfirestore 集合中子集合的字段值进行搜索
- javascript - ES6 基于键 Typescript 或 Javascript 合并两个数组(数组内部包含另一个数组)
- javascript - 加载文档后,有些东西正在滚动回 0,0
- android - 如何解决“无法从网站打开相机”的问题
- sql-server - 从非对称密钥创建登录并分配一些权限后,如何枚举权限