-3

I'm trying to create a table where the first row contains 1 button, and the other rows contain multiple columns. Example picture:

enter image description here

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: example 2

I've looked at other stackOverflow posts, but those answers contain dead links, which are no help to me.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
FrankK
  • 482
  • 8
  • 23
  • 2
    Swing? JavaFX? Your own attempt to far? – achAmháin Oct 23 '17 at 12:36
  • @notyou sorry, added the swing tag. my own attempt is based on this link: https://stackoverflow.com/questions/1475543/how-to-add-button-in-a-row-of-jtable-in-swing-java however, that only allows you to add button to a cell instead of an entire row – FrankK Oct 23 '17 at 12:42
  • @AndrewThompson this is exactly what i needed, please write this in an answer so i can give you credit! – FrankK Oct 23 '17 at 13:54

1 Answers1

3

This is relatively easy by placing the button outside the table. Here is how to go about it:

Create a panel with a BorderLayout. Add the table (to a scroll pane) to the CENTER of the border layout. Add the button to the PAGE_START of the border layout. Job done.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433