The code below shows one way to do this with a JList. It will be a little more complicate for a JTable since you will need a second JPanel with a BorderLayout. You would add the table header to the North and the main panel to the Center. Then this panel would be added to the viewport or the scrollpane.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
public class ListBottom2 extends JFrame
{
JList list;
JTextField textField;
public ListBottom2()
{
DefaultListModel model = new DefaultListModel();
model.addElement("First");
list = new JList(model);
list.setVisibleRowCount(5);
JPanel box = new JPanel( new BorderLayout() );
box.setBackground( list.getBackground() );
box.add(list, BorderLayout.SOUTH);
JScrollPane scrollPane = new JScrollPane( box );
scrollPane.setPreferredSize(new Dimension(200, 100));
add( scrollPane );
textField = new JTextField("Use Enter to Add");
getContentPane().add(textField, BorderLayout.NORTH );
textField.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JTextField textField = (JTextField)e.getSource();
DefaultListModel model = (DefaultListModel)list.getModel();
model.addElement( textField.getText() );
int size = model.getSize() - 1;
list.scrollRectToVisible( list.getCellBounds(size, size) );
textField.setText("");
}
});
}
public static void main(String[] args)
{
ListBottom2 frame = new ListBottom2();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible( true );
}
}