Hi, Im new to GUI so im not sure how it works, what I actually want to achieve is to create a table taking an array(bi dimensional) filled with my data and then take 2 arrays (both String, unidimensional) depicting the type of data on the first array like this

array for when the purchase was made (day of the week)

of pur
and on the inside the array filled with data

i made a JFrame with a JTable inside, the JTable only lets me take the bi dimensional array and the unidimensional array, so i had to make my data array Object so that i could input the type of purchase
ive managed to set everything up and I made the JFrame like this
    public static JFrame frame(String []vecFilas, Object [][]mat){
    JFrame frame = new JFrame("Tabla de Informacion");
    JButton boton = new JButton("OK");        
    JScrollPane scrollPane = new JScrollPane(table(vecFilas, mat));
    frame.add(boton, BorderLayout.SOUTH);
    frame.add(scrollPane, BorderLayout.CENTER);
    return frame;

so that i could re-use this frame for different types of tables the problem is, when i call this frame on Main it doesnt stop there, it continues to immediatly run the next piece of program i did, in this case being a JOptionPane message, the window hovers above my frame... what I need is for it to stop doing that, to stop when i call the frame and then continue once the frame has been closed, that is the main issue here, the second thing I need is to set an action listener to the button I created there to close the window... cant seem to find it anywhere...