Bruce Xu

+ Follow
since Feb 09, 2006
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bruce Xu

Do we need to generate the javadoc documentation for private classes and methods?
In my B&S specification, it says:
Awkward or complex code should have descriptive comments, and javadoc style comments must be used for each element of the public interface of each class. You must create a full suite of documentation for the classes of the completed project. This must be generated using the tool "javadoc" and must be in HTML format. Provide javadoc documentation for all classes you write.

and it also says:
A subdirectory called javadoc, containing HTML/Javadoc documentation for all classes and interfaces you are submitting.

thanks in advance
hey, mustafa, congratulations!
Ask you a question, do you generate Java documentation for you private classes
and methods in your submission?
16 years ago
I prefer using JFormattedTextField.
Hopefully following can give u some hints.
import javax.swing.JFormattedTextField
import javax.swing.text.DefaultFormatterFactory;
import java.text.NumberFormat;
import javax.swing.text.NumberFormatter;
NumberFormat format = NumberFormat.getNumberInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setMinimum(new Integer(0));
formatter.setMaximum(new Integer(255));
If you need more flexible&custmozied requirements, you probably need to overwrite some functions of "Formatter" or create you owner "Format" class.

here is the official tutorial:
16 years ago
hey,Yupp Cook,thanks for the hints.
I have considered such way.But I'm probably going to wrap the function with some locking so that the client GUI will display the snapshot of the database at the time when the "findByCriteria" is called.Therefore the Client GUI will not display some unmatched results.
Just let the clients feel good.
hi,ranchs,be glad to meet you guys here.
I have read the posts for some time so I put some questions of mine here.
My assignment is B&S and there's a function in the "" interface:

//Returns an array of record numbers that match the specified
//criteria. Field n in the database file is described by
//criteria[n]. A null value in criteria[n] matches any field
//value. A non-null value in criteria[n] matches any field
//value that begins with criteria[n]. (For example, "Fred"
//matches "Fred" or "Freddy".)
public long[] findByCriteria(String[] criteria);

Then,how to make sure that the record numbers the "findByCriteria" returns are up-to-date to client?
For example, if a client calls the "findByCriteria" and get returning {2,3,5,8}.But immediately after getting the record numbers, another client access the record "5" (just an example) and go to update it. Then how do you make sure the client GUI displays these records correctly?Because you only get record numbers,not the REAL records.
The point here is that the "findByCriteria" is a little bit misleading provided by SUN.If I were the "" designer,I would like writing it as "public String[] findByCriteria(String[] criteria);" or returning a list of record objects.

We need to wrap this function with some locking mechanism if we wanna realize the "search" utility?! (I don't think client lay can directly call this function.)

Correct me if my assumption is not right.
thanks in advance
In my current project I created 4 TextField inputs for IP address,such as:
and for each TextField,the requirements are:
1.only numbers allowered
2.only allows 3-digit number
3.numbers must be between 0~255
(for any violations to above requirements,users will get beeps)

my first solution is using JFormatterTextField:
editFormat = NumberFormat.getNumberInstance();
NumberFormatter EditFormatter = new NumberFormatter(editFormat);
EditFormatter.setMinimum(new Double(0));
EditFormatter.setMaximum(new Double(255));
EditFormatter.setAllowsInvalid(false);//don't comment out this line
TextField1 = new JFormattedTextField(new DefaultFormatterFactory(
it works,but not perfect,because you cannot backspace the first digit.

In my second solution,I'm trying to use KeyAdapter to control KeyEvents on these TextFields,however still not perfect.

Is there any simple ways or utilities in Java to solve the similar problems?
Especially about IP address input format?

thanks in advance
16 years ago