I have a problem with JTable: I have a table with the columns CODE, DESCRIPTION, QUANTITY, PRICE, CATALOG, and NUMBER_PAGE, and I need the code, quantity and price columns to only accept numbers. I have tried the events and I can not solve.
This is my code:
public Principal() throws UnsupportedLookAndFeelException, ParseException {
initComponents();
SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.BusinessBlackSteelSkin");
//agrega los campos a la tabla
String [] col = {"Codigo","Descripción","Cantidad","Precio","Catálogo","#Página"};
modelo = new DefaultTableModel(col,1);
tabla.setModel(modelo);
frameIngresaOrden.dispose();
frameModOrdenes.dispose();
frameVerOrdenes.dispose();
this.setExtendedState(MAXIMIZED_BOTH);
Pane.add(frameIngresaOrden);
Pane.add(frameModOrdenes);
Pane.add(frameVerOrdenes);
TableColumn catalogo = tabla.getColumnModel().getColumn(4);
TableColumn numeroPag = tabla.getColumnModel().getColumn(5);
comboBox.addItem("ÉSIKA");
comboBox.addItem("CYZONE");
comboBox.addItem("L'BEL");
llenarComboBox();
catalogo.setCellEditor(new DefaultCellEditor(comboBox));
numeroPag.setCellEditor(new DefaultCellEditor(comboBox2));
int rw=tabla.getSelectionModel().getMinSelectionIndex();
int cl=tabla.getColumnModel().getSelectionModel().getLeadSelectionIndex();
}
Actually I do not carry much of the code because I was designing the interface and from there starting to program the data entry. I leave the image as a reference; The idea is to fill in the data cell by cell: