title: How to position properly buttons with SWING/JButton in table/panel/JFrame
body: <p>I'm reading info from file and put it in a table. The code for this is not mine, but is exactly what I need so I'm trying to keep it and make it useful for me. What I need to add are 5-6 buttons and the functionality for them, but being totally new to working with <code>SWING</code> I'm having really hard time to complete both - keeping my existing code and adding the buttons on a proper positions.</p>
  
  <p>This is my file, the first part is where the table is made and where I try to include the code for one button:</p>
  
  <pre><code>public class DataFileTable extends JPanel {
    public DataFileTable(String dataFilePath) {
      JTable table;
      DataFileTableModel model;
      Font f;
  
      f = new Font("SanSerif",Font.PLAIN,24);
      setFont(f);
      setLayout(new BorderLayout());
  
      model = new DataFileTableModel(dataFilePath);
  
      table = new JTable();
      table.setModel(model);
      table.createDefaultColumnsFromModel();
      //Try to add button
      JButton button = new JButton("First Button");
      button.setSize(80,20);
      button.setVerticalAlignment(SwingConstants.BOTTOM);
      button.setHorizontalAlignment(SwingConstants.RIGHT);
      //End button part
      JScrollPane scrollpane = new JScrollPane(table);
      scrollpane.add(button);//Add button 
      add(scrollpane);
  
      }
  </code></pre>
  
  <p>and the second part is mostly the <code>main</code> function:</p>
  
  <pre><code>public Dimension getPreferredSize(){ 
  
      return new Dimension(400, 300);
      }
  
   public static void main(String s[]) {
      JFrame frame = new JFrame("Data File Table");
      DataFileTable panel;
  
      panel = new DataFileTable("customers.dat");
  
      frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
      frame.setForeground(Color.black);
      frame.setBackground(Color.lightGray);
      frame.getContentPane().add(panel,"Center");
  
      frame.setSize(panel.getPreferredSize());
      frame.setVisible(true);
      frame.addWindowListener(new WindowCloser());
      }
   }
  
  class WindowCloser extends WindowAdapter {
   public void windowClosing(WindowEvent e) {
     Window win = e.getWindow();
     win.setVisible(false);
     System.exit(0);
      }
  }
  </code></pre>
  
  <p>Here is a PrintScreen of what I get with this code:</p>
  
  <p><img src="https://i.stack.imgur.com/Riqnj.png" alt="enter image description here"></p>
  
  <p>I'm not looking for the best look and feel, but it would be really nice if I can keep the current code and add the buttons somewhere in the bottom. I tried to add the button directly to the frame form the <code>main</code> with <code>frame.add(button)</code> but then even though I have set a size the button takes all the space and the table is no more visible.</p>