public class table extends JPanel implements ActionListener{
JButton addInfo;
public table(String dataFilePath) {
JTable table;
model model;
Font f;
f = new Font("SanSerif",Font.PLAIN,24);
setFont(f);
setLayout(new BorderLayout());
model = new model(dataFilePath);
table = new JTable();
table.setModel(model);
table.createDefaultColumnsFromModel();
GridLayout layout = new GridLayout(80,30);
addInfo = new JButton("Add Data");
addInfo.setSize(80, 30);
addInfo.addActionListener(this); //action listener is somewhere below
//i'm not good at swing...and I don't know how to make the button
//appear AFTER the table rather than right on top of it...
add(addInfo);
JScrollPane scrollpane = new JScrollPane(table);
add(scrollpane);
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e){
System.out.println("Can't set look and feel:" + e.getMessage());
e.printStackTrace();
}
}
This class is a table with the model "model" (model is another one of my classes). I tried to add a button, but I need the button to be located beneathe the table rather than on top of the table. Is this possible?