Tahir Abbas

Ranch Hand
+ Follow
since May 05, 2007
Merit badge: grant badges
For More
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tahir Abbas

try this website for step by step beginning level tutorial

http://www.abbasacademy.com/

9 years ago
In my find method there is also no Record Not Found exception and there are comments above the method " A null value in criteria[n] matches any field value".

In my method I calculated total number of records then it checks in all not deleted records so I dont need Record Not Found exception for find method. But I used readRecord() mehtod inside the find() method, this readRecord() method throws RecordNotFoundException.

Secondly if null value is passed in method's array parameter i.e criteria[n] then all record number are returned as its asked in methods signature. Then on client side it does filteration again and passes the exact matched records in JTable. If no match found then only fields names as headings appear at the top of JTable.

Best Regards!
In my application when user selects Booking item from menu it shows a panel for user that displays all field values in JLabels except ownerID that displays in JTextField. In the bottom it has two buttons for moving to next and previous record as well as a combo box that shows all record numbers so user can select any record randomly. then there are buttons for Reservation and Cancellation.

I used cardlayout and in my search result there is an extra column for record numbers so user can know which record (number) he wants to reserve. then my booking form shows one complete record at time but here in this form he can see only one record so he need to see the search results for comparative records. Is this approach reasonable but I observed here many ranchers used JTable for the selection of required record to book.

Other question is this that I am thinking in array of String[] data all values except for OwnerID should be null, ({null, null, null, null, null, gettxtOwnerID().getText().trim()} ) then pass this to update method there it'll check if any field value is non-null and also match value length with field lenght , then update it with the new value.

In case of udatation it'll show dialog box updated successfully. Here I dont need to refresh the data from database as it shows one record at a time thats directly coming from database.

Another thing is un-booking that I think can be done by just sending empty value not null with the (almost) existing code, no need of new method for cancel booking. but on the other hand its not required so extra headache.

Thanks in Advance
Best Regards!
Hi to everyone,

My booking form shows one record at a time. The database field Names and values are in JLabels. Only Customer ID value displays in text box. I applied
txtOwner = new JFormattedTextField(new MaskFormatter("########")); on text box to show and get value for Reservation. There are buttons to show next and previous records.

If I input 8 digits in txtOwner but I dont Reserve this record and move to next or previous record that has blank/less than 8 digits in Customer ID field. then txtOwner does not update with new vlaue whenever all other fields get the new value according to new record. txtOwner displays the old value if 8 digits were given. I cannot overwrite this txtOwner with blank or less than 8 digits value.

If I just use * instead of # then it works good for 1-8 alphanumeric characters but you know I just need numeric data.

Thanks!
I'll highly appreciate your help.
Best Regards!
Thanks! K. Tsang,

Infact to cover many things in less lines I didn't copy all code. It has add menu items, mnenomic and accelerator keys for Search by Name Location and for Name or/and Location search. Action listeners are also working good, showing result in JTable in the center. But menu does not work with keyboard, only Alt+F works then Arrow Keys, Enter or Esc does not work.

Now I am going to copy all my project in new workspace, may be it'll solve the problem.
Thanks!
I am copying some sample code from my programme. I can use menu bar with mouse. AcceleratorKeys work, Alt+F moves control to menu bar but I cannot move from one menu item to other with the help of arrow keys as well as Enter and Esc Keys also dont work.


Thanks!
Hi,

In my application menu bar appears properly and it works good with mouse but Arrow keys, Enter and Esc keys dont work. I am using Eclipse.

I will highly appreciate any help in this regard.

Thanks! in Advance.
Congratulations! on this big Success.
14 years ago
Thanks! Roel

Its very easy to just display data in JTAble, no need to go beyond the requirements and ofcourse if I'll use Swing in future then I'll use IDE.

This time my JTable shows Field Names and an extra column Serial Number. All columns have equal width, as default. Table displays all screen wide. I didn't apply any TableModel or any other option. Do you think its enough because it fulfills the requirement "Result must be in JTable".

Or What formatting do you think I should apply. There are 100 Marks for General Consideration.

Best Regards!
Hi to everyone,

I want to make the width of columns in JTable according to the width of biggest cell. But for this I think I need to read almost all the record set. It will definately slow down the processing speed so its not looking me a good solution.

Another solution that I am thinking is to extend the length of heading titles (array of field names) by filling it with space, accroding to database schema and then adjust the the column width according to these headers. But in some cases column width may be unnecessarialy wide.

I would like to know your opinion to get a better solution.

Thanks! in Advance
Best Regards!
Tahir
Thank you very much my javaranch buddies,

Now I decided one single method to search:-
{null, null, null, null, null, null} All recorcds No. will return then some method to get Records. Am I right ?

For any other non-null value I'll get the Record number, if value exist. Non-null value may be one or may be all. So OR will apply automatically for Name or Location / (it may be AnyField OR AnyField). It looks me very reasonable approach (Almost implemented).

For AND, Ignore case, Exact Match I should apply some filteration in gui, but this may increase number of lines over there. but looking good solution.

Another thing I used Patterns [(Pattern.compile(field[0], Pattern.CASE_INSENSITIVE, Pattern.compile(field[1])]. Is it right or is there any better possibility available.
Best Regards!

Yea now I am thinking only one method before this my implementation approach requires more lines of code so I was thinking to organise it in multiple methods, in a separate file. But still thinking how to recognise that which guest selected And and which selected OR (Name and/or Location). Because main method will be in Data file and I used singleton.
Hi there,

I am posting how I am going to implement the public long[] findByCriteria(String[] criteria) to know Is my approach reasonable or do I need some changes.

For each search Name, Location, Name or Location, Name and Location client has separate form.
Clint will call findByCriteria(String[] criteria) if it was from the search Name form then {"ABC", null, null, null, null, null} if location then {null, "Can", null, null, null, null} if Name and/or location {"ABC", "Can", null, null, null, null} will be set in the array (to pass String[] criteria) now control will transfer to findByCriteria() method in data file. Here it will check does first element in array has (non null)value then need to call Search(name) or 2nd has value then call Search(location) or 1st and 2nd both have values then call Search(name, OrLocation) ) / Search(name, andLocation) (or any of array item is non null). then according to array elements it will call Search(name), Search(Location), , (Search(specialty), Search(size), ...). These all methods I'll keep in another file. so findByCriteria() actually only tranfers control to the appropriate method in another file, is it okay.

If 1st value in array will non null then Program'll get it know that it need to search by name. If 2nd value in array will non null then Program'll get it know that it need to search by location.

Now problem is when it is Name or Location / name and Location then how to differenciate or/and to call the exact method.

I am thinking to pass and extra value in array (String[] criteria) to tell "Or condition will apply/ and condition will apply" Is it right or how should I recognize the and/or condition.

PS: One function may also be enough that search according to any one or more non-null value(s) but still thinking how to identify AND/OR. may be instance variable or pass some extra value in array parameter
Thanks! in advance
Best Regards
Thanks! for help.

One thing that I got of using getter and setter is to provide security of data and in future any other programmer can use these methods for extension of program. But this way do I need to provide getter and setter for menu bar(s) and even for JLabel(s), Am I right.


In my program I used cardLayout. Different panels come from different files. If I keep all swing components private then I'll need to call getter and setter for every thing including JPanels, . This way in some files number of lines will increase multiple times.
Best Regards!
I also used java.io.RandomAccessFile to deal with the database. In database first there is information about database e.g; magic cookie value, number of fields etc then the record data in database starts. Data file section in instruction file will be very useful for dealing with database. If you search on this forum you'll get many useful threads regarding your problem.