Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 24th, 2005, 3:23 AM   #1
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Unhappy Grafical aplication

I have to make a grafical aplication. It takes it's input from a file where i have a name on each line. It has to have 2 buttons : UP and DOWN, in order to show 3 names at a time. Example:
On pressing down it will show: first 3 names, If pressed again it will show the next 3.. if u press up .. the first three .. and so on.

I'm not sure how to do this . I tride to group 3 lines at a time in a string ... but i don't know how to make it stop printing. I press DOWN once ...it showld print the first 3 then to stop ... until i've pressed it again .... help
__________________
Don't take life too seriously, it's not permanent !
xavier is online now   Reply With Quote
Old Jan 24th, 2005, 9:37 AM   #2
EdSalamander
Programmer
 
EdSalamander's Avatar
 
Join Date: Dec 2004
Location: Tucson, AZ, USA
Posts: 80
Rep Power: 4 EdSalamander is on a distinguished road
Send a message via AIM to EdSalamander
Show us your code, it'll help us help you.
__________________
I can pick my friends. And I can pick my nose. So, why can't I pick my friend's nose?
EdSalamander is offline   Reply With Quote
Old Jan 24th, 2005, 11:52 AM   #3
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Well i'd post if there was something to post. I wrote an aplication that prints the contents of a file.... I need some ideeas on how to do the 3 line movement...3 lines up .. 3 lines down
__________________
Don't take life too seriously, it's not permanent !
xavier is online now   Reply With Quote
Old Jan 24th, 2005, 12:54 PM   #4
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
stick all the lines in some data structure, and print the next three. doubly-linked list would work.
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Jan 24th, 2005, 1:52 PM   #5
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
how can i make it start printing from the 5-th line for example...?
__________________
Don't take life too seriously, it's not permanent !
xavier is online now   Reply With Quote
Old Jan 24th, 2005, 9:59 PM   #6
EdSalamander
Programmer
 
EdSalamander's Avatar
 
Join Date: Dec 2004
Location: Tucson, AZ, USA
Posts: 80
Rep Power: 4 EdSalamander is on a distinguished road
Send a message via AIM to EdSalamander
One way you could do it...
First, have your program copy all the names into an array, one name/line per index, then you can reference any line/name with that index in the array minus 1. For example, if you wanted to display the 5th, 6th and 7th lines, you print out array[i-1], array[i] and array[i+1] where i = 5. Your up and down arrows then would decrease or increase i by three (respectively) and update/rewrite the display.
__________________
I can pick my friends. And I can pick my nose. So, why can't I pick my friend's nose?
EdSalamander is offline   Reply With Quote
Old Jan 25th, 2005, 12:43 PM   #7
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Ok, .... how do i add them into an array ? what type of array? And ... after i press the down button, let's say it shows the first 3 names. after.. on pressing the button again it showld continue from where it was ... hmm ... i haven't tried anything yet .. but on the other hand i have no ideea on how to do that .

But first ... the array .....?
__________________
Don't take life too seriously, it's not permanent !
xavier is online now   Reply With Quote
Old Jan 25th, 2005, 5:50 PM   #8
marcusami
Newbie
 
Join Date: Jan 2005
Location: Ky
Posts: 3
Rep Power: 0 marcusami is on a distinguished road
This is a bit brute forced and just somethign i wrote out, not exact code, but hopefully it will give u an idea. It first creates 9 Name cells, then u get names from user and it puts them n cells; then if a button is clicked up display the first three; if this is done again show next three, and if pushed down go down 3.
I hope this helps it might be confusing more than helping

String [] Name = new String[8];
for(int index=0; index<Name.length; index++){
Name[index] = userName;
}

int Num =0;
if(buttonClickedUp){

for(Num; Num <=2; Num++){
System.out.println(Name[Num]);

if(buttonClickUp){

for(Num=3; num<=5; num++);
System.out.println(Name[Num]);
}

if(buttonClickDown){

for(Num=2; num >=0; num--;
System.out.println(Name[Num]);
}
}
__________________
[color=DarkSlateGray]
Marcus
marcusami is offline   Reply With Quote
Old Jan 26th, 2005, 12:21 AM   #9
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
String[] c=new String[300];
try{
			fr=new FileReader("name.txt");
			bfr=new BufferedReader(fr);
			int i=0;

			for(;;){

				String lCrt=bfr.readLine();
				if(lCrt==null)break;
				c[i]=lCrt;
				i++;
				System.out.println(c[i]); //test to see if it works
			
			}
			bfr.close();
			}catch(IOException e){
						System.out.println(e);
						System.exit(1);}
I keep getting "null".... i don't know why...
__________________
Don't take life too seriously, it's not permanent !
xavier is online now   Reply With Quote
Old Jan 26th, 2005, 11:03 PM   #10
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
....Help.... why do i keep getting "null"?
__________________
Don't take life too seriously, it's not permanent !
xavier is online now   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC