1
It is possible to hide and lock the last line of a DefaulTableModel
?
I have this difficulty and I am not able to solve it. If it is not at least possible to hide this line?
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class Main extends JFrame {
DefaultTableModel model = new DefaultTableModel(new Object[][] {
{"Jack","19","Masculino"}, {"Eddie","56","Masculino"}, {"Gina","34","Feminino"},
{"Klaus","18","Masculino"}, {"Erika","20","Feminino"}, {"Roberto","29","Masculino"},{"Maria","30","Feminino"} },
new Object[] { "Nome:", "Idade:", "Sexo:" });
public Main() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTable table = new JTable(model);
getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
pack();
}
public static void main(String arg[]) {
new Main().setVisible(true);
}
}
I’d like to hide the last line.
Good.. It is necessary a minimum, complete and verifiable example, for a question whether it is possible to block a row from any table? if the table has 5 lines, is it possible to block the last? sorry for the question, it is my first topic.
– Lucas16
And where is your tablemodel? Which line needs to be blocked? When it needs to be blocked?
– user28595
put an example of tablemodel, I need the last line to be hidden as soon as I open the frame, I just need it to be hidden
– Lucas16
I updated the answer.
– user28595