Randy Valadez

Greenhorn
+ Follow
since Feb 08, 2001
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 Randy Valadez

Are we suppose to create this function and place it in the data class. Also do we only use this function for an exact match or to populate all records via a wild character such as *.* or all?
etc etc... Thanks any examples of this search method would be appreciated.
Thanks Randy.
Thanks Rudy I am going back to the sun site and reread the JTable Models..
Thanks Randy
I have a class FlyTableModel I have put it in the suncertify.db package but methods not found also I will include my errors with this class when I compile...How do I get the reference to DataClass
package suncertify.db;
import javax.swing.table.*;
import suncertify.db.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.lang.Throwable.*;
import java.io.*;
public class FlyTableModel extends AbstractTableModel
{

Data fly = new Data("db.db");
public int getColumnCount()
{
return getFieldInfo().length;
}
public int getRowCount()
{
return getRecordCount();
}
public Object getValueAt(int row, int col)
{
String[] values = (String[])valueDInfo.toArray(new String[0]);
return values[row][col];
}
public String getColumnName(int col)
{
return getFieldInfo()[col].getName();
}
}
errors////////////////////////////////////errors/////
C:\scjd\starting\suncertify\db\FlyTableModel.java:13: Exception java.io.IOException can't be thrown in initializer.
Data fly = new Data("db.db");
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:16: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo().length;
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:23: Method getRecordCount() not found in class suncertify.db.FlyTableModel.
return getRecordCount();
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:29: Undefined variable or class name: valueDInfo
String[] values = (String[])valueDInfo.toArray(new String[0]);
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:31: [] can only be applied to arrays. It can't be applied to java.lang.String.
return values[row][col];
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:39: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo()[col].getName();
^
6 errors
Process completed with exit code 1
Thanks in Advance Randy
also when I want to populate my JTable from the client is this appropiate::::::given my above class:::::
FlyTableModel model = new FlytableModel();
JTable table = new JTable(model);
I have a class FlyTableModel I have put it in the suncertify.db package but methods not found also I will include my errors with this class when I compile...How do I get the reference to DataClass
package suncertify.db;
import javax.swing.table.*;
import suncertify.db.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.lang.Throwable.*;
import java.io.*;
public class FlyTableModel extends AbstractTableModel
{

Data fly = new Data("db.db");
public int getColumnCount()
{
return getFieldInfo().length;
}
public int getRowCount()
{
return getRecordCount();
}
public Object getValueAt(int row, int col)
{
String[] values = (String[])valueDInfo.toArray(new String[0]);
return values[row][col];
}
public String getColumnName(int col)
{
return getFieldInfo()[col].getName();
}
}
errors////////////////////////////////////errors/////
C:\scjd\starting\suncertify\db\FlyTableModel.java:13: Exception java.io.IOException can't be thrown in initializer.
Data fly = new Data("db.db");
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:16: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo().length;
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:23: Method getRecordCount() not found in class suncertify.db.FlyTableModel.
return getRecordCount();
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:29: Undefined variable or class name: valueDInfo
String[] values = (String[])valueDInfo.toArray(new String[0]);
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:31: [] can only be applied to arrays. It can't be applied to java.lang.String.
return values[row][col];
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:39: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo()[col].getName();
^
6 errors
Process completed with exit code 1
Thanks in Advance Randy
also when I want to populate my JTable from the client is this appropiate::::::given my above class:::::
FlyTableModel model = new FlytableModel();
JTable table = new JTable(model);
I have a class FlyTableModel I have put it in the suncertify.db package but methods not found also I will include my errors with this class when I compile...How do I get the reference to DataClass
package suncertify.db;
import javax.swing.table.*;
import suncertify.db.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.lang.Throwable.*;
import java.io.*;
public class FlyTableModel extends AbstractTableModel
{

Data fly = new Data("db.db");
public int getColumnCount()
{
return getFieldInfo().length;
}
public int getRowCount()
{
return getRecordCount();
}
public Object getValueAt(int row, int col)
{
String[] values = (String[])valueDInfo.toArray(new String[0]);
return values[row][col];
}
public String getColumnName(int col)
{
return getFieldInfo()[col].getName();
}
}
errors////////////////////////////////////errors/////
C:\scjd\starting\suncertify\db\FlyTableModel.java:13: Exception java.io.IOException can't be thrown in initializer.
Data fly = new Data("db.db");
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:16: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo().length;
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:23: Method getRecordCount() not found in class suncertify.db.FlyTableModel.
return getRecordCount();
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:29: Undefined variable or class name: valueDInfo
String[] values = (String[])valueDInfo.toArray(new String[0]);
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:31: [] can only be applied to arrays. It can't be applied to java.lang.String.
return values[row][col];
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:39: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo()[col].getName();
^
6 errors
Process completed with exit code 1
Thanks in Advance Randy
also when I want to populate my JTable from the client is this appropiate::::::given my above class:::::
FlyTableModel model = new FlytableModel();
JTable table = new JTable(model);
Thanks very much I will work on that..
I have a class FlyTableModel I have put it in the suncertify.db package but methods not found also I will include my errors with this class when I compile...How do I get the reference to DataClass

package suncertify.db;
import javax.swing.table.*;
import suncertify.db.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.lang.Throwable.*;
import java.io.*;
public class FlyTableModel extends AbstractTableModel
{


Data fly = new Data("db.db");
public int getColumnCount()
{
return getFieldInfo().length;

}

public int getRowCount()
{

return getRecordCount();
}
public Object getValueAt(int row, int col)
{

String[] values = (String[])valueDInfo.toArray(new String[0]);

return values[row][col];
}
public String getColumnName(int col)
{
return getFieldInfo()[col].getName();
}

}
errors////////////////////////////////////errors/////
C:\scjd\starting\suncertify\db\FlyTableModel.java:13: Exception java.io.IOException can't be thrown in initializer.
Data fly = new Data("db.db");
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:16: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo().length;
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:23: Method getRecordCount() not found in class suncertify.db.FlyTableModel.
return getRecordCount();
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:29: Undefined variable or class name: valueDInfo
String[] values = (String[])valueDInfo.toArray(new String[0]);
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:31: [] can only be applied to arrays. It can't be applied to java.lang.String.
return values[row][col];
^
C:\scjd\starting\suncertify\db\FlyTableModel.java:39: Method getFieldInfo() not found in class suncertify.db.FlyTableModel.
return getFieldInfo()[col].getName();
^
6 errors
Process completed with exit code 1
Thanks in Advance Ray
also when I want to populate my JTable from the client is this appropiate::::::given my above class:::::
FlyTableModel model = new FlytableModel();
JTable table = new JTable(model);
Hi Rudy I am trying to implement your example to my JTable how did you get it to work any other replies welcome.
Thanks Randy
I just want to populate all records into the
Object[][] rows instead of hardcoding them into the rows array.
Thanks in advance Randy

else if(source == searchButton)
{
try {
Data myData = new Data("db.db");
myData.find("SA001");
System.out.println(myData.recordCount);
//I made recordCount public to use it from data class
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
JOptionPane.showMessageDialog(this, "Database Connection Failed", "Error", JOptionPane.ERROR_MESSAGE);
}
private Object[][] rows = { {"SA001","SFO","DEN","SpeedyAir","400","Sun","13:40","20m","36"},{"RA987","DEN","ABQ","RainvilleAir","756"
,"Fri","18:20","2h10m","11"}};

String[] columnHeads = {"Flight#","Origin","Destination","Carrier","Cost","Date","Time","Duration","Seats"};
My Question:: I can hardcode the first 2 records and they display correctly in JTable. How can I populate my JTable with all records when I click my search button using my above 2 Dimensional Object array.
Thanks in Advance Randy
Anyone in chicago area that would like to start a study group.
Thanks Randy
Im curious has anyone subclassed data although the methods are already provided in the data class?
Thanks in Advance Randy
I will populate mine from the database, Thus, you can update database without having to recode your combo box.
Hope this helps.
Thanks very much srilatha that fixed the problem.
have a nice day randy