Answer the question
In order to leave comments, you need to log in
How to add regular expressions to a java table?
I want to add input filtering to some of the table rows. I heard that you can screw regular expressions to it, but how to do it?
public void drawConfigTable(ArrayList<ArrayList<String>> config) {
configFieldTypes = new Vector<>();
configTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
//заполнить массивы полей и значений
Vector<String> columns = new Vector<>();
columns.add("Name");
columns.add("Value");
Object[] colArr = columns.toArray();
DefaultTableModel tableModel = new DefaultTableModel(colArr, 0);
try {
for (int i = 0; i < config.size(); i++) {
Vector<String> row = new Vector<>();
row.add(config.get(i).get(0));
String changedEncode = config.get(i).get(2);
row.add(changedEncode);
configFieldTypes.add(config.get(i).get(1));
tableModel.addRow(row);
}
} catch (Exception e) {
System.out.println(e.toString());
}
//рисовать таблицу
configTable.setModel(tableModel);
configTable.setAutoscrolls(true);
configTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
JScrollPane scroll = new JScrollPane(configTable,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
additionalFrame = new JFrame("PagingTableModel");
additionalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
additionalFrame.setContentPane(scroll);
additionalFrame.setBounds(30, 50, 1300, 600);
additionalFrame.setVisible(true);
saveDataBase.setEnabled(true);
getConfigButton.setEnabled(false);
laStatus.setText("Простаивает");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question