I have a jTable for a future pool that I want to make. The problem is that when I create the jTable, I open where it says model, I put the number of columns and the number of rows and I also put the name but in the jFrame only the jTable leaves completely empty, pls help.
PS: I'm working with Eclipse Luna
PS2: I do not know why the Hello from the beginning is deleted lmao
PS3: I've edited this about 20 times
package com.ucab.ve;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JTable;
import java.awt.BorderLayout;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import java.awt.Font;
public class Quiniela {
private String[] columnNames = {"Fecha", "Equipo 1", "Equipo 2", "Goles
Equipo 1", "Goles Equipo 2"};
private JFrame frame;
private JTable table;
/**
* Launch the application.
*/
public static void main(String[] args) {
String[] equipos={};
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Quiniela window = new Quiniela(equipos);
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Quiniela(String[] equipos) {
initialize(equipos);
}
/**
* Initialize the contents of the frame.
*/
private void initialize(String[] equipos) {
frame = new JFrame();
frame.setBounds(100, 100, 658, 612);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
table = new JTable();
table.setBounds(0, 33, 642, 573);
table.setModel(new DefaultTableModel(
new Object[][] {
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
},
new String[] {
"Fecha", "Equipo 1", "Equipo 2", "Goles Equipo 1", "Goles Equipo 2"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, true, true
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
table.getColumnModel().getColumn(0).setResizable(false);
table.getColumnModel().getColumn(0).setPreferredWidth(83);
table.getColumnModel().getColumn(1).setPreferredWidth(88);
table.getColumnModel().getColumn(2).setPreferredWidth(89);
table.getColumnModel().getColumn(3).setPreferredWidth(93);
table.getColumnModel().getColumn(4).setPreferredWidth(107);
frame.getContentPane().setLayout(null);
table.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
frame.getContentPane().add(table);
JLabel lblFecha = new JLabel("Fecha");
lblFecha.setFont(new Font("Lato", Font.PLAIN, 13));
lblFecha.setBounds(36, 11, 46, 14);
frame.getContentPane().add(lblFecha);
JLabel lblEquipo1 = new JLabel("Equipo 1");
lblEquipo1.setFont(new Font("Lato", Font.PLAIN, 13));
lblEquipo1.setBounds(152, 11, 50, 16);
frame.getContentPane().add(lblEquipo1);
JLabel lblEquipo2 = new JLabel("Equipo 2");
lblEquipo2.setFont(new Font("Lato", Font.PLAIN, 13));
lblEquipo2.setBounds(274, 11, 50, 16);
frame.getContentPane().add(lblEquipo2);
JLabel lblGolesEquipo1 = new JLabel("Goles Equipo 1");
lblGolesEquipo1.setFont(new Font("Lato", Font.PLAIN, 13));
lblGolesEquipo1.setBounds(389, 11, 86, 16);
frame.getContentPane().add(lblGolesEquipo1);
JLabel lblGolesEquipo2 = new JLabel("Goles Equipo 2");
lblGolesEquipo2.setFont(new Font("Lato", Font.PLAIN, 13));
lblGolesEquipo2.setBounds(525, 11, 86, 16);
frame.getContentPane().add(lblGolesEquipo2);
}
public String regresar(String info){
return info;
}
}