473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Swing address book problem

6
Hiya everyone. I'm doing a project to code a swing program records basic information on people, with the ability to edit, delete, and view the data, and output the data to a file. I chose a text file for this. To see the format that I used in logging the information, please look at problem1.jpg. I have done all except the edit and delete windows. For both windows, the program will read the data from the file and populate the fields such as

First Name: first_name
Last Name: last_name

and so on. Now the first problem comes from the fact that multiple records are stored in the text file, and the program must go to the next record (forwards/backwards) to edit/delete the data. Is there a way to go to the next record from the record format that I made up? Okay, so look at problem1.jpg again. What I want to do is to move from the first dataset (First Name: Justin...Phone: 7373732) to the next one (Julius...83838) and so on for other entries.

Next is the editing/deleting part. I know how to change the data, problem is, I want to update the current data, and from what I know, if I place the append to the PrintWriter function it will add a new entry to the file. If I remove the append argument, PrintWriter will clear the other records and just write the changes that I specified on the textFields. What I want is to change the data that I want to change and leave the others alone. Now for the delete part, I believe (I haven't start this part) that I would just set the values to " ", just plain spaces, so like

Expand|Select|Wrap|Line Numbers
  1. output.println("First Name: "+fname);
would be
Expand|Select|Wrap|Line Numbers
  1. output.println("");
Correct me if I'm wrong on that one. I believe if I do this successfully it will leave a big gap between the entries that are not deleted. Is there a way to rearrange the data when an entry is deleted?

Okay so what have I done. For populating the fields I did a dirty way of using the scanner, then using skip to "skip" the strings that I don't need then retrieve the unskipped strings to show on the textFields.

e.g.

Expand|Select|Wrap|Line Numbers
  1. Scanner s = new Scanner (new FileInputStream("data.txt"));
  2.       s.skip("First Name: ");
  3.       String fname = s.nextLine();
  4.       //edFname is the name of the textField
  5.       edFname.setText(fname);
and this goes on for every field. Aside from that I have nothing. I'm on a brick wall here, and I've tried all possible ways to address the problem. If you have any problems understanding what I typed, please refer to the attachments below, and if you have additional questions please do ask me. Thank you.
Attached Images
File Type: jpg problem1.jpg (33.8 KB, 77 views)
File Type: jpg problem2.jpg (72.4 KB, 70 views)
File Type: jpg problem3.jpg (27.7 KB, 75 views)
Apr 25 '12 #1
0 1330

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: truckmen | last post by:
Hello All, I still can't figure it all out. I am trying to create a web page (using php) where: 1) A visitor add his or her name to an address book that can also be viewed online by other...
2
by: someone | last post by:
Hi, I currently have an Access 97 database that includes a field for contact name of a user. This user will almost always have a valid email address contained in the personal address book of...
2
by: Phil Stanton | last post by:
Can anyone give me sone code to add addresses from a query to an Outlook Address book. The problem is that I want to add the new email addresses to a distribution list, not to the main email list ...
5
by: Ignacio Domínguez | last post by:
Hi. Is there a way of accessing the address book, similar to what Outlook Express does, using C#? Thanks Ignacio Domínguez
0
by: Bob Avallone | last post by:
MetaPro Systems Inc. Visual Studio Dot Net Tips & Tricks #3 – Direct Access to Your Outlook Address Book. Project Type: VS.NET Windows Application Code Behind: Visual Basic I have a project...
5
by: ttoboobz | last post by:
Help anyone... I'm creating a simple address book java program that would store 100 records. The GUI should be able to accept the name, address, phone no., and email add of a person by clicking a...
11
cjbrx3115
by: cjbrx3115 | last post by:
Hey guys- I just got this email from my friend. I'm not sure it will really work (it's a forward), so I'm askin' you people. Well, here it is: ...
1
by: Lpitt56 | last post by:
I am running MS Access 2007 and I want to update an Outlook Address book from my Access Database. I started out by importing the Outlook Address Book as a linked table and it linked fine. I then...
2
by: watusiboy | last post by:
do you have any idea of how to implement the yahoomail classic address book in php? i have created one but there are things i can't figure out: the address book(which is a popup window) is...
10
by: Mike Miller | last post by:
Hi, Am wanting to send email with php and need to access the global outlook address book. Are there any examples/tutorials on how to do this? M
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.