Helllo
Iam praveen,
here i created three textfields, one submit button & table in that window itself using 'Swings'. If i give the details in text that should go to table by the click of submit button.but iam not getting this.so please do this favour
& be thankful.
with regards
praveen
Import java.lang.Object;
import javax.swing.table.DefaultTableModel;
public class tabletest extends javax.swing.JFrame {
String[][] row = null;
String[] title=new String[3];
private int i;
/** Creates new form tabletest */
public tabletest() {
initComponents();
setTitle("table test");
setVisible(true);
System.out.print("NO Database Needed");
title[0]="Name";
title[1]="Desig";
title[2]="id";
}
/*
" In middle of this two source one generated code will be there that will be done by dragging ur fields to ur frame. THIS IS FOR netbeans IDE "
*/
private void b1ActionPerformed(java.awt.event.ActionEvent evt) {
row=new String[4][3];
// TODO add your handling code here:
String s1=t1.getText();
System.out.println(" event 1");
String s2=t2.getText();
System.out.println(" event 2");
int k=Integer.parseInt(t3.getText());
String s3=""+k;
System.out.println(" event 3");
try{
// for(int i=0;i<=2;i++)
row[i][0]=s1;
row[i][1]=s2;
row[i][2]=s3;
i++;
}catch(Exception e){
e.printStackTrace();
}
table.setModel(new DefaultTableModel(row,title));
}
private void b2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
t1.setText("");
t2.setText("");
t3.setText("");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tabletest().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton b1;
private javax.swing.JButton b2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel l1;
private javax.swing.JLabel l2;
private javax.swing.JLabel l3;
private javax.swing.JPanel p2;
private javax.swing.JScrollPane scp1;
private javax.swing.JTextField t1;
private javax.swing.JTextField t2;
private javax.swing.JTextField t3;
private javax.swing.JTable table;
// End of variables declaration
}
You are on the wrong website for this type of inquiry. This is a self help website for the repair and use of consumer manufactured products
199 views
Usually answered in minutes!
×