Over 10 states are now reporting cases of the killer spinach spawning the E. Coli bacteria. Federal health officials are advising Americans to throw out all the bagged spinach.
I never had a problem with throwing away spinach personally. I just wish this news story broke when I was a kid being forced to eat spinach - I would have really milked this one - years of spinach-free adolescence.
Has anyone heard any similar stories about brussel sprouts?
Saturday, September 16, 2006
Friday, September 15, 2006
Refresh a JTable from a JDBC connection
I have a Swing application that uses a JTable and JScrollPane to display data from an Access database via a JDBC connection.
Even though I had properly coded the SQL INSERT statement and the data was loading into my database, the JTable was not refreshing with the new record. I tried the .revalidate() and the .repaint() methods to no avail.
Finally, after reading Ben Hendry's Mastering JTable I was able to sort this out.
In my JButton ActionListener I added the TableModel.addRow method and inserted the newly inserted records into the JTable as well. Followed by a .revalidate() and the data properly displayed without even a flicker in my application.
Moral of the story - always use Model-View-Control (MVC) architecture and separate your view from your data and controls.
Even though I had properly coded the SQL INSERT statement and the data was loading into my database, the JTable was not refreshing with the new record. I tried the .revalidate() and the .repaint() methods to no avail.
Finally, after reading Ben Hendry's Mastering JTable I was able to sort this out.
In my JButton ActionListener I added the TableModel.addRow method and inserted the newly inserted records into the JTable as well. Followed by a .revalidate() and the data properly displayed without even a flicker in my application.
Moral of the story - always use Model-View-Control (MVC) architecture and separate your view from your data and controls.
Mastering the JTable
Hunting around the web looking for a way to "refresh" the JTable that is built from a database connection. I found the Bob Hendry articles which can be seen here. There are quite informative but don't answer the question in full. Still looking:
Mastering the JTable
Using JTable - part one
Using JTable - part two
Mastering the JTable
Using JTable - part one
Using JTable - part two
How to Refresh a JTable in a JScrollPane?
I have created a Swing application that has a JTable with a JScrollPane that is populated with data from an Access database through a JDBC connection.
There are fields where you can add data and insert a record to this database. I am trying to add an event to the JButton so when you click the button and add a new record, that the JTable refreshes and newly queries the data source.
I've searched for how to handle this and tried the revalidate(), repaint() methods and these don't cause a change.
There are fields where you can add data and insert a record to this database. I am trying to add an event to the JButton so when you click the button and add a new record, that the JTable refreshes and newly queries the data source.
I've searched for how to handle this and tried the revalidate(), repaint() methods and these don't cause a change.
Tuesday, September 12, 2006
Monday, September 11, 2006
Eclipse Visual Editor vs. Jigloo
Ok, I've been using the Eclipse Visual Editor for all of 15 minutes and I am sold. Up until now, I've been using Cloudgarden's Jigloo free version, yet after getting constantly annoyed by Jigloo's constant modifications to my code, prevention of using builders and the incessant warnings about how you are using the free version and that this can not be used for commercial use, I had it.
It is much easier to build with the Model View Control (MVC) architecture using the VE tool as opposed to the Jigloo builder.
Here are some comparisons and reviews of these GUI builder tools:
Jigloo Review
Comparison of Java GUI Builders
Comparison with Matisse
IBM Giving Away VE Source Code to Eclipse
It is much easier to build with the Model View Control (MVC) architecture using the VE tool as opposed to the Jigloo builder.
Here are some comparisons and reviews of these GUI builder tools:
Jigloo Review
Comparison of Java GUI Builders
Comparison with Matisse
IBM Giving Away VE Source Code to Eclipse
How to Install VE (Visual Editor) in Eclipse
I've dabbled with Jigloo and found that Eclipse has its own GUI builder called VE. This needs the GEF and EMF plugins to work.
Here is an excellent resource that answers all the questions I had when getting started with VE, from the installation to how it works.
Here is an excellent resource that answers all the questions I had when getting started with VE, from the installation to how it works.
Sunday, September 10, 2006
JList or JTable - I need a multi-column display
I'm gradually coming to grips with programming user interfaces in Java. Read a bit on the MVC (Model View Control) concept and while I see its value, it is a bit too steep a gradient at this point. I am starting off getting the basics of the Swing GUI and have been using Jgoodies with the Jigloo Windows builder. Even that is a bit steep as I want to know how to build these from the ground up and using the drag and drop tools resulted in skipping some of the basics that left me hanging, when trying to modify and customize what Jigloo provide.d
What has helped learn this the fastest has been to work out some simple application that will be useful and then laying out a UML diagram including Use Case for the requirements, Activity Diagrams and Class Diagrams. A programmer is lost in the woods without these design tools. Then I've taken one element at a time, the JDBC database access, pulling up a list and displaying this, etc.
I am up to a point where I need to display a simple list of entries from a database. The list should have 3 columns. I've only been able to get this to work with one column so far. So what I am looking into is whether it would be better to just use the JTable or figure out a "multi-column" JList.
Here are some resources to figure this out:
Code Guru
Java Sun
Dream In Code
And don't forget to use your Study Tech!
What has helped learn this the fastest has been to work out some simple application that will be useful and then laying out a UML diagram including Use Case for the requirements, Activity Diagrams and Class Diagrams. A programmer is lost in the woods without these design tools. Then I've taken one element at a time, the JDBC database access, pulling up a list and displaying this, etc.
I am up to a point where I need to display a simple list of entries from a database. The list should have 3 columns. I've only been able to get this to work with one column so far. So what I am looking into is whether it would be better to just use the JTable or figure out a "multi-column" JList.
Here are some resources to figure this out:
Code Guru
Java Sun
Dream In Code
And don't forget to use your Study Tech!
Friday, September 08, 2006
Java isDate() Solved!
With the help of some friends in Javalobby I was able to get a solution to the isDate() issue for Java.
Below is a method that simulates the Visual Basic isDate() method and is configurable so you can set what you consider are the valid date formats.
I modifed this and added the "Jan|Feb|Mar|Apr..." and "JAN|FEB|MAR|APR|..." to the regex so that the method now validates the formats I needed to check.
I am now implementing this in my application.
-------------------------------------------------
import java.util.ArrayList;
import java.util.regex.Pattern;
public class IsDateTestClass {
public static boolean isDate(CharSequence date) {
// some regular expression
String time = "(\\s(([01]?\\d)|(2[0123]))[:](([012345]\\d)|(60))"
+ "[:](([012345]\\d)|(60)))?"; // with a space before, zero or one time
// no check for leap years (Schaltjahr)
// and 31.02.2006 will also be correct
String day = "(([12]\\d)|(3[01])|(0?[1-9]))"; // 01 up to 31
String month = "((1[012])|(0\\d))"; // 01 up to 12
String year = "\\d{4}";
// define here all date format
ArrayList patterns = new ArrayList();
patterns.add(Pattern.compile(day + "[-.]" + month + "[-.]" + year + time));
patterns.add(Pattern.compile(year + "-" + month + "-" + day + time));
// here you can add more date formats if you want
// check dates
for (Pattern p : patterns)
if (p.matcher(date).matches())
return true;
return false;
}
public static void main(String[] args) {
ArrayList dates = new ArrayList();
dates.add("05.10.1981"); // swiss date format (dd.MM.yyyy)
dates.add("05-10-1981");
dates.add("07-09-2006 23:00:33");
dates.add("2006-09-07 23:01:24");
dates.add("2003-08-30");
dates.add("2003-30-30"); // false
dates.add("some text"); // false
for (String d : dates)
System.out.println(isDate(d));
}
}
-------------------------------------------------
Below is a method that simulates the Visual Basic isDate() method and is configurable so you can set what you consider are the valid date formats.
I modifed this and added the "Jan|Feb|Mar|Apr..." and "JAN|FEB|MAR|APR|..." to the regex so that the method now validates the formats I needed to check.
I am now implementing this in my application.
-------------------------------------------------
import java.util.ArrayList;
import java.util.regex.Pattern;
public class IsDateTestClass {
public static boolean isDate(CharSequence date) {
// some regular expression
String time = "(\\s(([01]?\\d)|(2[0123]))[:](([012345]\\d)|(60))"
+ "[:](([012345]\\d)|(60)))?"; // with a space before, zero or one time
// no check for leap years (Schaltjahr)
// and 31.02.2006 will also be correct
String day = "(([12]\\d)|(3[01])|(0?[1-9]))"; // 01 up to 31
String month = "((1[012])|(0\\d))"; // 01 up to 12
String year = "\\d{4}";
// define here all date format
ArrayList
patterns.add(Pattern.compile(day + "[-.]" + month + "[-.]" + year + time));
patterns.add(Pattern.compile(year + "-" + month + "-" + day + time));
// here you can add more date formats if you want
// check dates
for (Pattern p : patterns)
if (p.matcher(date).matches())
return true;
return false;
}
public static void main(String[] args) {
ArrayList
dates.add("05.10.1981"); // swiss date format (dd.MM.yyyy)
dates.add("05-10-1981");
dates.add("07-09-2006 23:00:33");
dates.add("2006-09-07 23:01:24");
dates.add("2003-08-30");
dates.add("2003-30-30"); // false
dates.add("some text"); // false
for (String d : dates)
System.out.println(isDate(d));
}
}
Thursday, September 07, 2006
Java isDate() Function
New to Java, but learning fast and definitely experiencing the "Paradigm Shift", however I find it odd that there is no isDate() function like there is in Visual Basic.
As mentioned in an earlier post, I ran into a Java Date Conversion issue where the date format that I was expecting and turned out in the live data tests, to be a different format. This was after building over 500 test cases that test each of the business rules programmed into a Drools Rules (now Jboss) processor.
So obviously, I want to have all possible date formats accounted for so the solution is to have a function that loops through each of the possible date formats and check if the string parses into a valid Date object using that particular SimpleDateFormat.
I know this can be done using try-catch blocks, but I want to create a more elegant approach calling my custom isDate() function.
Checking aroung Javalobby and other places to see if anyone has already solved this, or if I need to create from scratch.
As mentioned in an earlier post, I ran into a Java Date Conversion issue where the date format that I was expecting and turned out in the live data tests, to be a different format. This was after building over 500 test cases that test each of the business rules programmed into a Drools Rules (now Jboss) processor.
So obviously, I want to have all possible date formats accounted for so the solution is to have a function that loops through each of the possible date formats and check if the string parses into a valid Date object using that particular SimpleDateFormat.
I know this can be done using try-catch blocks, but I want to create a more elegant approach calling my custom isDate() function.
Checking aroung Javalobby and other places to see if anyone has already solved this, or if I need to create from scratch.
Wednesday, September 06, 2006
Tom Cruise, Baby Suri, Photos Released
Scientology Today New Site Design
There is a newly designed Scientology Today website. This has daily news about Scientology activities around the world. Scientologists, helping others, using Scientology technology to improve conditions in their environments.
Today's news story has a picture of a chinese VM and a little girl she is helping.
I've noticed the Scientology sites are getting more and more aesthetic and easier to get around in.
Some of the new sites that are stunning are the Youth For Human Rights and the Scientology Handbook sites.
Go and take a look at these sites and let me know your feedback...
Today's news story has a picture of a chinese VM and a little girl she is helping.
I've noticed the Scientology sites are getting more and more aesthetic and easier to get around in.
Some of the new sites that are stunning are the Youth For Human Rights and the Scientology Handbook sites.
Go and take a look at these sites and let me know your feedback...
Wednesday, August 30, 2006
ACM, Safari and the Professional Development Center
I found a gem. This is the ACM, Association for Computing Machinery. This association has a yearly membership of less than $100 and with this you get access to over 1000 online books, including the O'Reilly series and over 500 online courses.
I've enrolled in about 5 different courses and any one of these would have cost hundreds of dollars each if I had enrolled in one of the online college degree services or other online computer courses.
With this yearly membership you get full access to the Safari collection of books as well.
I am currently enrolled on the full OOAD, Object Oriented Analysis & Design curriculum which contains 6 different courses, gradiently walking you through from basic OO concepts all the way through detailed UML diagrams. Every course contains "Pre" and "Post" examinations so you if you already are an expert at a subject, the course is customized to fit what you still need to work on based on your "Pre" test results. Then you must get over 80% passing rate for you to be considered "complete" with any course. You are directed back to the exact point you missed and you can clear up any misunderstood words and re-study.
Definitely an "A+" for ACM and the Professional Development Center.
I've enrolled in about 5 different courses and any one of these would have cost hundreds of dollars each if I had enrolled in one of the online college degree services or other online computer courses.
With this yearly membership you get full access to the Safari collection of books as well.
I am currently enrolled on the full OOAD, Object Oriented Analysis & Design curriculum which contains 6 different courses, gradiently walking you through from basic OO concepts all the way through detailed UML diagrams. Every course contains "Pre" and "Post" examinations so you if you already are an expert at a subject, the course is customized to fit what you still need to work on based on your "Pre" test results. Then you must get over 80% passing rate for you to be considered "complete" with any course. You are directed back to the exact point you missed and you can clear up any misunderstood words and re-study.
Definitely an "A+" for ACM and the Professional Development Center.
Tuesday, August 29, 2006
I know I have a Coffee Addiction, but a Mental Disorder?
The American Psychiatric Association has been at it again. One of the latest entries in the DSM "The Handbook of Mental Disorders", is the Caffeine Disorder. If you are a coffee drinker and get a headache when you don't drink coffee, you can now get free Prozac, paid for by your insurance company. This is because the DSM is used as a shopping list and if it is in the DSM, you can prescribe it. This is total B.S. The disorders entered into the DSM are voted on by a group of psychs each year and they have admitted there is no scientific evidence to back up these disorders. Here is the latest caffeine related disorder.
Anyone who feels this is a bunch of B.S. should check out the CCHR website as they are doing an excellent job of exposing these frauds.
Anyone who feels this is a bunch of B.S. should check out the CCHR website as they are doing an excellent job of exposing these frauds.
Sunday, August 27, 2006
Star UML - pretty good... What about Poseidon?
Ok, Star UML is pretty good. It felt a little too restricted to code-direct diagrams as opposed to a more abstract modeling environment which is how I like to start.
Poseidon has been downloaded by over a million people. But there is no free version bar a 30-day free trial.
I am going to dig a little more into this and see if it can't just satisfy my UML needs.
Poseidon has been downloaded by over a million people. But there is no free version bar a 30-day free trial.
I am going to dig a little more into this and see if it can't just satisfy my UML needs.
Star UML Design Tool
Ok, I downloaded the Star UML Design tool. Looks like an open source UML tool. Sounds promising. I'll give it a review in a bit.
UML Free Tools
Searching the web, trying to find a good simple UML tool. After studying some basics on the UML method I am finding numerous applications where a UML design tool with be great. Of course one could be simulated using Word or Open Office, but it would be much nicer for a series of templates to be laid out ahead of time for each of the different types of diagrams and have these easily available.
I've tried the Visual Paradigm Community Edition which is free and is very nice however you can't print anything off without these annoying watermarks.
I've tried the Visual Paradigm Community Edition which is free and is very nice however you can't print anything off without these annoying watermarks.
Saturday, August 26, 2006
Scientology Stress Tests - Do They Really Work?
Anyone been to the Big Apple lately or walked down Hollywood Blvd and seen the guys in red Dianetics shirts, with the E-Meters and big signs saying "FREE STRESS TEST"?
Here is how this works:
What they do is sit you down and give you a pair of cans to hold. You are asked to think about people and situations in your life that may be causing you stress. The meter reacts to thought as thought is energy. A small electrical current is passed from one hand, through your body and out the other hand. When you think of something stressful, your thought contains more electrical resistance which is measured on the E-Meter with a right motion of the needle.
I have seen this done myself and I have given Stress Tests. The result is quite impressive. I was able to pinpoint exact areas of people's lives that are causing them stress. After receiving the stress test, most people want to find out how to get rid of that stress.
This is what Dianetics is all about. Getting rid of the negative emotion of past incidents which cause you stress in the present.
Here is an on-line version of the Stress Test that you can do.
Here is how this works:
What they do is sit you down and give you a pair of cans to hold. You are asked to think about people and situations in your life that may be causing you stress. The meter reacts to thought as thought is energy. A small electrical current is passed from one hand, through your body and out the other hand. When you think of something stressful, your thought contains more electrical resistance which is measured on the E-Meter with a right motion of the needle.
I have seen this done myself and I have given Stress Tests. The result is quite impressive. I was able to pinpoint exact areas of people's lives that are causing them stress. After receiving the stress test, most people want to find out how to get rid of that stress.
This is what Dianetics is all about. Getting rid of the negative emotion of past incidents which cause you stress in the present.
Here is an on-line version of the Stress Test that you can do.
Friday, August 25, 2006
Java Date Conversion !?!@@#@:(
Is anyone else perturbed about Java dates! 2 weeks of programming based on what was thought to be the "expected" date format of "yyyy-mm-dd" and it turns out to be "dd-mmm-yyyy" and nothing works. Ok, but my program should be able to handle all the various types of common date formats that could be sent in. So I figure, sure, others must have run into this, let's find a library on the net. After nearly an hour of searching, no luck. I guess I'll just build my own...
Subscribe to:
Posts (Atom)