Here is a link that describes how to create a directory in Java:
Java IO Reference
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...
Wednesday, August 23, 2006
SmallTalk approach to OOP
1. Everything is an object. Think of an object as a fancy variable; it stores data, but you can “make requests” to that object, asking it to perform operations on itself. In theory, you can take
any conceptual component in the problem you’re trying to solve (dogs, buildings, services, etc.) and represent it as an object in your program.
Some language designers have decided that object-oriented programming by itself is not adequate to easily solve all programming problems, and advocate the combination of various approaches into multiparadigm programming languages.
2. A program is a bunch of objects telling each other what to do by sending messages. To make a request of an object, you “send a message” to that object. More concretely, you can think of a message as a request to call a method that belongs to a particular object.
3. Each object has its own memory made up of other objects. Put another way, you create a new kind of object by making a package containing existing objects. Thus, you can build
complexity into a program while hiding it behind the simplicity of objects.
4. Every object has a type. Using the parlance, each object is an instance of a class, in which “class” is synonymous with “type.” The most important distinguishing characteristic of a class is “What messages can you send to it?”
5. All objects of a particular type can receive the same messages. This is actually a loaded statement, as you will see later. Because an object of type “circle” is also an object of type
“shape,” a circle is guaranteed to accept shape messages. This means you can write code that talks to shapes and automatically handle anything that fits the description of a shape. This
substitutability is one of the powerful concepts in OOP.
An excerpt from Thinking in Java.
Quoted
any conceptual component in the problem you’re trying to solve (dogs, buildings, services, etc.) and represent it as an object in your program.
Some language designers have decided that object-oriented programming by itself is not adequate to easily solve all programming problems, and advocate the combination of various approaches into multiparadigm programming languages.
2. A program is a bunch of objects telling each other what to do by sending messages. To make a request of an object, you “send a message” to that object. More concretely, you can think of a message as a request to call a method that belongs to a particular object.
3. Each object has its own memory made up of other objects. Put another way, you create a new kind of object by making a package containing existing objects. Thus, you can build
complexity into a program while hiding it behind the simplicity of objects.
4. Every object has a type. Using the parlance, each object is an instance of a class, in which “class” is synonymous with “type.” The most important distinguishing characteristic of a class is “What messages can you send to it?”
5. All objects of a particular type can receive the same messages. This is actually a loaded statement, as you will see later. Because an object of type “circle” is also an object of type
“shape,” a circle is guaranteed to accept shape messages. This means you can write code that talks to shapes and automatically handle anything that fits the description of a shape. This
substitutability is one of the powerful concepts in OOP.
An excerpt from Thinking in Java.
Quoted
Tuesday, August 22, 2006
Jigloo Eclipse Windows Builder?
Building GUIs for rich client apps in Eclipse is not the easiest thing in the world. I'm looking for windows builders comparable to the Net Beans GUI builder.
I am downloading the Jigloo GUI builder which sounds pretty good but that is coming from company who made it.
What about WindowsBuilderPro? This is a commercial product, not free like Jigloo. How is it better?
I'll try both and see for myself...
On the install, Jigloo is very simple and is just like any other Eclipse plugins. Just copy to the features and plugins directories and your done. WindowBuilder on the other hand has you walk through a install wizard which took only a couple minutes to run through. (Make sure you don't have Eclipse running during the install).
WindowsBuilder has several example apps you can try. In 5 minutes of testing this builder I found it very user friendly. I liked the "quick view" feature where without even compiling you can get a feel for how your app will look during runtime. Now on to Jigloo.
After the few minutes I found it easy to create a basic app. Nothing difficult. I liked the two screen (code/app) view that shows the two-way changes so if you edit the GUI the code changes or you edit the code and the GUI changes.
So far they are both comparable products and I'll spend a bit more time using each on an actual application to see which is the better product.
I am downloading the Jigloo GUI builder which sounds pretty good but that is coming from company who made it.
What about WindowsBuilderPro? This is a commercial product, not free like Jigloo. How is it better?
I'll try both and see for myself...
On the install, Jigloo is very simple and is just like any other Eclipse plugins. Just copy to the features and plugins directories and your done. WindowBuilder on the other hand has you walk through a install wizard which took only a couple minutes to run through. (Make sure you don't have Eclipse running during the install).
WindowsBuilder has several example apps you can try. In 5 minutes of testing this builder I found it very user friendly. I liked the "quick view" feature where without even compiling you can get a feel for how your app will look during runtime. Now on to Jigloo.
After the few minutes I found it easy to create a basic app. Nothing difficult. I liked the two screen (code/app) view that shows the two-way changes so if you edit the GUI the code changes or you edit the code and the GUI changes.
So far they are both comparable products and I'll spend a bit more time using each on an actual application to see which is the better product.
The Set Interface
Here is how this works. Set is an interface that extends the Collections object. HashSet is an instance of "Set". You can't just instantiate the interface. You do this with the concrete HashSet, TreeSet or LinkedHashSet implementations. Each of these handle the Collection differently.
The HashSet doesn't care what sequence the data is in, but will ensure no duplicates are allowed.
The TreeSet will sort the data and keep it in that order and the LinkedHashSet will retain the sortation that it originally was stored in.
Pretty simple eh.
The HashSet doesn't care what sequence the data is in, but will ensure no duplicates are allowed.
The TreeSet will sort the data and keep it in that order and the LinkedHashSet will retain the sortation that it originally was stored in.
Pretty simple eh.
Subscribe to:
Posts (Atom)