Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need to have my program take information from text file Plus my pie chart is in wrong place

 
laurie Watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my last class and I am confused i really need a good grade to pass the class I need it to reaad a file then show a pie chart heres the first part of the code i will also include my piechart code and text file thanks for your help its due tonight


the pie chart code


it won't allow me to post a txt document here but is not reading my text document and my pie chart sets on top of my readout how do I move it





 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Did you write all that code yourself? What exactly is your question about it? It's a lot of code to look through. If you have a specific problem with it, then explain, preferrably with a short piece of code, what you don't understand.

Also, please use a meaningful title for your posts instead of something like "Please help".
 
laurie Watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure where the problem is it is not reading my external file.
I think the problem may be here but I am not sure


String line;

BufferedReader br = new BufferedReader(new FileReader("loanterms.txt"));

while ((line = br.readLine()) != null) { standardTerms.add(line);

termList.addItem(line);

}

br.close();


int numberOfLoans = standardTerms.size();

//allocate the arrays

rates = new String[numberOfLoans];

years = new String[numberOfLoans];

String [] temp;


for (int index = 0; index < numberOfLoans; index ++)

{

temp = standardTerms.get(index).split(",");



years[index] = temp[0];

rates[index] = temp[1];
}

} catch (Exception ex) {

System.out.println(ex.toString());

}

}

I also do not know how to position my pie chart so it is not on top of the rest of the readout thanks
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote: . . . It's a lot of code to look through. . . .
It's even worse with the double-spacing, which I have got rid of; that makes it harder to read.

Why have you got so many fields in your classes? Most of those buttons and components could be local variables in your constructor.

Also, I think this thread would sit better in our GUIs forum, so I shall move it.
 
laurie Watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay I got it to read my text file but it won't calculate from those choices i will calculate the data i input still have the piechart problem.

I think this is the code you need
calculate.addActionListener(new ActionListener() {

I think it has to some how be tied into the combo box but I am not sure how
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic