Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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





 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 72650
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic