My problem is that I have a JTable
with 2 vector data for data & column names respectively,
Vector<String> rowOne = new Vector<>();
rowOne.addElement("Harry");
rowOne.addElement("100414");
rowOne.addElement("21");
rowOne.addElement("239438");
rowOne.addElement("08/21/2016");
rowOne.addElement("30000");
Vector<String> rowTwo = new Vector<>();
rowTwo.addElement("Gordon");
rowTwo.addElement("34353");
rowTwo.addElement("25");
rowTwo.addElement("2538");
rowTwo.addElement("07/ 16/2016");
rowTwo.addElement("20000");
Vector<Vector> rowData = new Vector<>();
rowData.addElement(rowOne);
rowData.addElement(rowTwo);
Vector<String> columnNames = new Vector<>();
columnNames.addElement("Name");
columnNames.addElement("Cc");
columnNames.addElement("Age");
columnNames.addElement("Phone");
columnNames.addElement("Date");
columnNames.addElement("Amount");
DefaultTableModel model = new DefaultTableModel(rowData, columnNames);
table = new JTable(model);
As we can see is a normal JTable
with 6 columns, in which the fourth one is a string representing a date.
I tried to add a button with a action listener like this, in order to iterate over all rows of the JTable at the column 4 in order to get all string date values to compare it with the current date to verify if they're older than 30 days.
public void actionPerformed(ActionEvent e)
{
else if(e.getActionCommand().equals("limPago"))
{
DefaultTableModel model = (DefaultTableModel)table.getModel();
int num = model.getRowCount();
for(int i = 0; i < num; i++)
{
//Right here i don't know how to identity the columns with date greater
//than 30 days and take the jtable index corresponding to that row.
}
}
I need to get the index row corresponding to the Object
of JTable
that have the column 4 date with 30 days older.