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?

Items will be aligned in a container in the order that you add them. So yes, it is possible. Is that what you're asking? If you wanted the button above, just add the button first and add the table second.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.