1
I have the code under a JTextField
, where you wanted to type numbers separated by comma, and that by clicking on JButton
, data were added in a table column.
public class Dados extends javax.swing.JPanel {
public Dados() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
vNomes = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jLabel1.setText("Digite os valores separados por virgula");
jButton1.setText("Formar tabela");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"classes", "Xi", "Fi", "Fac"
}
));
jScrollPane1.setViewportView(jTable1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(vNomes, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(88, 88, 88)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(214, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(vNomes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(412, Short.MAX_VALUE))
);
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField vNomes;
// End of variables declaration
}
Present a [mcve] so that it is possible to test the code and simulate the problem.
– user28595
There is nothing implemented there about doubt, what you have tried to do?
– user28595
I don’t know how to do anything, I just know the logic that would be to type numbers to fill the columns of the table , for example column Xi, making the first one then I will do the next.
– Claudio
Your doubt in this way is too wide. I suggest a read on Jtable, learn a little to handle and try something, and when painting a specific question, ask again.
– user28595
Unless you want to, actually, make a text typed in a textfield to be inserted in a column, but your question does not specify which column and whether the addition will be fixed in that column.
– user28595
that’s right, typed text, after clicking the button, fill in the column, can be qq one, and can be fixed
– Claudio
You need to explain better how this addition should be made, otherwise it becomes difficult to elaborate something.
– user28595
ok, la, I need to fill a table with some numbers that will be typed, these numbers must fill a column in the table, example column Xi, when the user type, 1,2,3,4,5... click the button add, each value fills a row of the column, got it?
– Claudio
Is each column value separated by comma? What if it has more comma values than columns?
– user28595
no, each value will be for a row.. of the same column would be:
– Claudio
See the answer below.
– user28595