Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
¿Cómo eliminar filas con ciertos valores de Jtable?

Tengo una Jtable que cargué con valores de un archivo .csv, pero crea una nueva fila para cada instancia del 13/05/2013 que aparece en el archivo, así:

https://i.stack.imgur.com/phdTs.jpg

Me gustaría eliminar todas las filas con esta información de la tabla, pero no estoy seguro de cómo hacerlo. ¿Alguna sugerencia para mí?

Aquí está mi código para agregar los datos a la tabla, si ayuda:

 while (inputStream.hasNext()) { String data = inputStream.next(); String[] values = data.split(","); tableModel.insertRow(tableModel.getRowCount(), values); }//end of while block`

Para reiterar y ser completamente claro, quiero eliminar todas las filas que contienen "13/05/2013" de la tabla por completo. Y estoy usando el modelo de tabla predeterminado, por cierto.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Terminé aplicando un bucle for y una declaración if para que esto funcionara para mí.

 //remove rows with instances of "5/13/2013" for (int i = 0; i < tableModel.getRowCount(); i++) { if (((String)tableModel.getValueAt(i, 0)).equals("5/13/2013")) { tableModel.removeRow(i); }//end of if block }//end of for block

Ha funcionado bien para mí y se ha deshecho de cada una de esas filas. Esperemos que esto pueda ayudar a alguien más.

over 4 years ago · Santiago Trujillo Report

0

while(i < tableModel.getRowCount()) { //if the value at (i, 0) match the specified value the row will be removed /* if the row removed all row will move up and their index will be changed so you have to add a condition if the value from the table doesn't match the specified value the iterator i will iterate by one to jump to the next row */ if (((String)tableModel.getValueAt(i, 0)).equals("5/13/2013")) { tableModel.removeRow(i); }else { ++i; } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!