Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Faisal Ahmed

Greenhorn
+ Follow
since Aug 22, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Faisal Ahmed

Hi!
I want to run Oracle Report Builder Engine from FrontEnd(java).
Please mention me the steps i can proceed.
17 years ago
Hi!
I want to run Oracle Report Builder Engine from FrontEnd(java).
Please mention me the steps i can proceed.
Hi everybody!
Please help me to solve the problems below:
#1.I want ScrollBars in a FORM(extend JFrame) which is populated with
many Components.How can i do this.
#2.I have made JDialog opens from a FORM(extends JFrame) through
'Findbtn'.JDialog populated with JTable has been used for fetching data
from database. but the problem is how can I get text from JTable
to the textfield of Form.
17 years ago
Hi!!
AbstractTableModel has been used in my Jtable. Mymodel is the object of MyTableModel.When I use ‘Findbtn’ for query from oracle database . data is retrieved
,but at that time any new record cann’t be inserted below the existing record.General error message has been shown.Normally data can be inserted through ‘savebtn’.But I need to do it for Auto numbering.It means when I press the Enterbtn of the Keyboard it will increase 1 for the next record. I need it for IncrementID(field of a table).I have given the partial code of mine.Plz help me how can I insert data and create auto nubering with sample code or idea.
/////////////////////////////////////
class MyTableModel extends AbstractTableModel {
String[] columnNames = {"IncrementID","Designation","Department","Date"}; //&&&&&
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return NRows;
}
public String getColumnName(int col) {
return columnNames[col];
}
public Object getValueAt(int row, int col) {
return rowData[row][col];
}

public Class getColumnClass(int c) {
if(c==0) return Integer.class; //&&&&&&&
//if(c==1) return Integer.class;
if(c==1) return String.class;
if(c==2) return String.class;
if(c==3) return String.class;
if(c==4) return String.class;
return null;
}

public boolean isCellEditable(int row, int col) {
return true;
}

public void setValueAt(Object value, int row, int col) {
if (col==0){
rowData[row][0]=value;
}
if(col==1){
rowData[row][1]=value;
// showId(value.toString(), row);
// to load unit of measure combo
}
if(col==2){
rowData[row][2]=value;
}
if(col==3 ){//col 4 contains qty
rowData[row][3]=value;
int r=jTable1.getSelectedRow(); //?? r&nr
int nr=jTable1.getRowCount()-1;
if(r==nr)
insertRow();
}
if(col==4 ){//col 4 contains qty
rowData[row][col]=value;
}
}
//////////////////////////////////
void insertRow(){
int rows=myModel.getRowCount();
NRows=NRows+1;
int i=0;
if(rows>0)
i=rows;
rowData[i][0]=null;
rowData[i][1]="";
rowData[i][2]="";
rowData[i][3]="";
myModel.fireTableDataChanged();
}
////////////////////////actionevent for save/////////////////////////////
void jButtonSave_actionPerformed(ActionEvent e) {
setEmployeeTableData();
}

public void setEmployeeTableData(){
getSwingFieldsData();
PreparedStatement prepStatement=null;
try{
int numRows = jTable1.getRowCount();
for(int i=0; i<numRows; i++){
PreparedStatement stmt = con.prepareStatement("INSERT INTO TBL_INCREMENT VALUES (?, ?, ?, ?, ?)");

stmt.setInt(1, Integer.parseInt(rowData[i][0].toString()));
stmt.setInt(2, Integer.parseInt(strEMPMID));
// stmt.setInt(1, Integer.parseInt(rowData[i][0].toString()));
stmt.setString(3, rowData[i][1].toString());
stmt.setString(4, rowData[i][2].toString());
stmt.setString(5, rowData[i][3].toString());
stmt.execute();
stmt.clearParameters();

JOptionPane.showMessageDialog(null," Saved IncrementTable data");
}

}
catch(SQLException e){
JOptionPane.showMessageDialog(null,"User1 caught"+e.getMessage());
}
catch(Exception e1){
JOptionPane.showMessageDialog(null,"User2 caught"+e1.getMessage()+"\nError !");
}

}
}
Hi!!
AbstractTableModel has been used in my Jtable. Mymodel is the object of MyTableModel.When I use ‘Findbtn’ for query from oracle database . data is retrieved
,but at that time any new record cann’t be inserted below the existing record.Normally data can be inserted through ‘savebtn’.But I need to do it for Auto numbering.It means when I press the Enterbtn of the Keyboard it will increase 1 for the next record. I need it for IncrementID(field of a table).I have given the partial code of mine.Plz help me how can I insert data and create auto nubering with sample code or idea.
/////////////////////////////////////
class MyTableModel extends AbstractTableModel {
String[] columnNames = {"IncrementID","Designation","Department","Date"}; //&&&&&
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return NRows;
}
public String getColumnName(int col) {
return columnNames[col];
}
public Object getValueAt(int row, int col) {
return rowData[row][col];
}

public Class getColumnClass(int c) {
if(c==0) return Integer.class; //&&&&&&&
//if(c==1) return Integer.class;
if(c==1) return String.class;
if(c==2) return String.class;
if(c==3) return String.class;
if(c==4) return String.class;
return null;
}

public boolean isCellEditable(int row, int col) {
return true;
}

public void setValueAt(Object value, int row, int col) {
if (col==0){
rowData[row][0]=value;
}
if(col==1){
rowData[row][1]=value;
// showId(value.toString(), row);
// to load unit of measure combo
}
if(col==2){
rowData[row][2]=value;
}
if(col==3 ){//col 4 contains qty
rowData[row][3]=value;
int r=jTable1.getSelectedRow(); //?? r&nr
int nr=jTable1.getRowCount()-1;
if(r==nr)
insertRow();
}
if(col==4 ){//col 4 contains qty
rowData[row][col]=value;
}
}
//////////////////////////////////
void insertRow(){
int rows=myModel.getRowCount();
NRows=NRows+1;
int i=0;
if(rows>0)
i=rows;
rowData[i][0]=null;
rowData[i][1]="";
rowData[i][2]="";
rowData[i][3]="";
myModel.fireTableDataChanged();
}
////////////////////////actionevent for save/////////////////////////////
void jButtonSave_actionPerformed(ActionEvent e) {
setEmployeeTableData();
}

public void setEmployeeTableData(){
getSwingFieldsData();
PreparedStatement prepStatement=null;
try{
int numRows = jTable1.getRowCount();
for(int i=0; i<numRows; i++){
PreparedStatement stmt = con.prepareStatement("INSERT INTO TBL_INCREMENT VALUES (?, ?, ?, ?, ?)");

stmt.setInt(1, Integer.parseInt(rowData[i][0].toString()));
stmt.setInt(2, Integer.parseInt(strEMPMID));
// stmt.setInt(1, Integer.parseInt(rowData[i][0].toString()));
stmt.setString(3, rowData[i][1].toString());
stmt.setString(4, rowData[i][2].toString());
stmt.setString(5, rowData[i][3].toString());
stmt.execute();
stmt.clearParameters();

JOptionPane.showMessageDialog(null," Saved IncrementTable data");
}

}
catch(SQLException e){
JOptionPane.showMessageDialog(null,"User1 caught"+e.getMessage());
}
catch(Exception e1){
JOptionPane.showMessageDialog(null,"User2 caught"+e1.getMessage()+"\nError !");
}

}
}
17 years ago
Hi!!
I have used AbstractTableModel in my JTable.In case of multiple rows, i want to delete rows from interface as well as from database. As removeRow method is absent in AbstractTableModel.so DefaultTableModel has been used by casting but CastClassException throws. Here is Partial code(tried in many ways).Plz help me to solve the problem.
void jButtonCancel_actionPerformed(ActionEvent e) {
try{
jTable1.setModel(myModel); //jtable is object of JTable and myModel is of Abstract TableModel

DefaultTableModel model=((DefaultTableModel)jTable1.getModel());


int row=jTable1.getSelectedRow();
if(row>=0){
model.removeRow();
jTable1.revalidate();
model.fireTableDataChanged();
System.out.println("Rows Delete");
}
}
}
catch(Exception sq){
sq.printStackTrace();
sq.getMessage();
}

}
17 years ago
Hi!
I am in problem to validate the Text field which is assigned for Integer value.But the user input
the wrong one(i.e string).at that time it will show a warning message.please help..
17 years ago
I am in a problem to save,find and show data from Oracle dataBase into JTable(which is a field of a form)using Abstract Table Model and Cell Rendering and one column of the table will contain Combobox.Please helpme in a sample code or refernce.
Hi !!
I am in a confusion to save,find and update data from Oracle Databases into Jtable(a component of a Form) using AbstractTableModel & TableCellRenderer.Please help me in a sample code
or by references.
18 years ago