![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
|
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 ! |
|
|
|
|
|
#2 |
|
Programmer
|
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? |
|
|
|
|
|
#3 |
|
Professional Programmer
|
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 ! |
|
|
|
|
|
#4 |
|
Professional Programmer
|
stick all the lines in some data structure, and print the next three. doubly-linked list would work.
|
|
|
|
|
|
#5 |
|
Professional Programmer
|
how can i make it start printing from the 5-th line for example...?
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#6 |
|
Programmer
|
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? |
|
|
|
|
|
#7 |
|
Professional Programmer
|
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 ! |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Jan 2005
Location: Ky
Posts: 3
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#9 |
|
Professional Programmer
|
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);}![]()
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#10 |
|
Professional Programmer
|
....Help.... why do i keep getting "null"?
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|