This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!

David Shepherd

Ranch Hand
+ Follow
since Mar 02, 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 David Shepherd

I meant no ill regard. I was simply feeling a little too sparky when I was writing.
What you describe is an excellent idea. Is it deployable without having the user do any configuration?
20 years ago
Excellent ideas. Would anyone have a link to information on creating a connection pool, etc...
Thank you very much.
20 years ago
I created a class by extending JPanel. The idea is to combine a JLabel and a JTextField and simply return a text field with a label already attached. The duo would live inside of a small JPanel. I'm having trouble settin the size of the JPanel so that it is only as large as the JLabel/JTextField combo.
I know some of the layout managers override sizing. Is there one that will allow me to explicitly set the size of this little JPanel and not allow the JPanel I put it in to resize it?
20 years ago
Sorry for such a large post. I had some code from a techtips article that I use for a similar purpose. It prints to a file but I think it will give you some ideas on how to solve your problem. Hope it helps.

Code from --- http://developer.java.sun.com/developer/TechTips/1999/tt1021.html#tip2

public class SaveOutput extends PrintStream {
static OutputStream logfile;
static PrintStream oldStdout;
static PrintStream oldStderr;
SaveOutput(PrintStream ps)
{
super(ps);
}
// Starts copying stdout and
//stderr to the file f.
public static void start(String f) throws IOException
{ // Add a time stamp to the end of the file name.
f+="javaLogFile"+new java.util.Date().getTime()+".txt";
// Save old settings.
oldStdout = System.out;
oldStderr = System.err;
// Create/Open logfile.
logfile = new PrintStream(new BufferedOutputStream(new FileOutputStream(f)));
// Start redirecting the output.
System.setOut(new SaveOutput(System.out));
System.setErr(new SaveOutput(System.err));
}
// Restores the original settings.
public static void stop()
{
System.setOut(oldStdout);
System.setErr(oldStderr);
try {
logfile.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// PrintStream override.
public void write(int b)
{
try {
logfile.write(b);
} catch (Exception e) {
e.printStackTrace();
setError();
}
super.write(b);
}
// PrintStream override.
public void write(byte buf[], int off, int len)
{
try {
logfile.write(buf, off, len);
} catch (Exception e) {
e.printStackTrace();
setError();
}
super.write(buf, off, len);
}
}
20 years ago
Does anyone see a problem with this code. It seems to occasionally cause my program to just quit. I only use it for testing but I can't find anything wrong.

public static void printTableData(Vector v)
{System.out.println(" --- Table Data ----------------------");
try
{ for(int i =0; i<v.size(); i++)>
{int tempLength =((Vector)v.get(i)).size();
Vector innV =(Vector)v.get(i);
for(int x =0; x<tempLength; x++)>
{
System.out.print(" "+innV.elementAt(x));
}
System.out.print("\n");
}
}
catch(Exception e)
{
System.out.println("table problem");
e.printStackTrace();
}
}
20 years ago
Could be. I'm handling exceptions but maybe not in the right places.
Thanks for the ideas. Now I have somewhere to begin at least.
I can't figure this one out.
I have a singleton that creates a DB connection to an access database. The singleton is used in an Observer pattern and is the observable of a JTableModel based class.
I also have a dialog box that calls a static method of the singleton and adds some values to the database.
It seems to work. However, sometimes (I see no pattern to it) when I update the database the application just stops running. No stack trace, no error, nothing. I think I have it narrowed down to the methods that make DB connections. I make and close a connection to fill the table in the beginning and every time there is an update call. I'm thinking this may have something to do with it.
Any ideas would be greatly appreciated.
Are you talking about Javascript or Java?
20 years ago
Wait a minute. I have never seen a jar file that would execute an application on a double click. I think this guy is dreaming.
Making a java exe is not nearly that easy.
You can create a ".bat" file (create a text file, type in the command line command to run your java app, save the file with a .bat exentsion, now you can double click and get some action!)
There is also a javaToExe tool out there that probably uses a C++ Wrapper or something like that.
Additionally, you can use JNI and C++ to create a C++ executable that will start your program.
Do a search on this site for java exe and you'll get a ton of informative threads.
20 years ago
I can't figure this one out.
I have a singleton that creates a DB connection to an access database. The singleton is used in an Observer pattern and is the observable of a JTableModel based class.
I also have a dialog box that calls a static method of the singleton and adds some values to the database.
It seems to work. However, sometimes (I see no pattern to it) when I update the database the application just stops running. No stack trace, no error, nothing. I think I have it narrowed down to the methods that make DB connections. I make and close a connection to fill the table in the beginning and every time there is an update call. I'm thinking this may have something to do with it.
Any ideas would be greatly appreciated.
20 years ago
Has anyone implemented Allen Holub's visual proxy concept (pattern)? I'm looking for a simple example other than the ones on his web site.
I am using a Command pattern to seperate my user interface from my business logic. I will have quite a few dialog screens that will be triggered from the main frame. These Dialogs will in turn interact with the business layer and may need to be able to update the parent frame. I was considering just extending the Command pattern out another iteration and having the dialog classes conform to it.
Anyone have any better ideas or foresee any problems with that?
Thank you for you help.
I'm a little new to the pattern idea but it seems like I have a situation where a pattern may help.
I am beginning to build GUI screens for an application. It seems that I should be able to build the screens and centralize the event handling into one class. I would like to separate the GUI from the business logic as much as possible because I will not be involved in implementing the business logic. My idea is to have one central class that handles all of the GUI events and in turn knows what business logic (objects) to call in order to process the event. Finally, this event handler will update the GUI component. I think this is similar to the MVC architecture used for the swing components.
I would think this concept has been played out before and is available in the form of a pattern that may prevent me from making stupid mistakes.
Any input would be greatly appreciated. Thank you.
I have a JTable and I want to make a cell a different color depending on the value in one of the other columns of the same row. Basically, set the color of cells, on a cell by cell basis.
I have tried to create a custom table cell renderer that will change the background color if the component in the cell is not editable but I have not had much luck. Am I on the right track?
Can someone please give me some guidance. It can't be that hard but it's killing me.
Thank you.
20 years ago