简体   繁体   English

Java 创建表,第一行有一个按钮

[英]Java create table with a button on the first row

I'm trying to create a table where the first row contains 1 button, and the other rows contain multiple columns.我正在尝试创建一个表格,其中第一行包含 1 个按钮,其他行包含多列。 Example picture:示例图片:

在此处输入图片说明

How could I make this?我怎么能做到这一点?

I've attempted the following: add button to table but that only allows you to add a button like this:我尝试了以下操作: 将按钮添加到表格,但这仅允许您添加这样的按钮: 例子2

I've looked at other stackOverflow posts, but those answers contain dead links, which are no help to me.我看过其他 stackOverflow 帖子,但这些答案包含死链接,这对我没有帮助。

This is relatively easy by placing the button outside the table.通过将按钮放在桌子外面,这相对容易。 Here is how to go about it:以下是如何去做:

Create a panel with a BorderLayout .创建一个带有BorderLayout的面板。 Add the table (to a scroll pane) to the CENTER of the border layout.将表格(到滚动窗格)添加到边框布局的CENTER Add the button to the PAGE_START of the border layout.将按钮添加到边框布局的PAGE_START Job done.任务完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM