This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes I need to have my program take information from text file Plus my pie chart is in wrong place Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "I need to have my program take information from text file Plus my pie chart is in wrong place" Watch "I need to have my program take information from text file Plus my pie chart is in wrong place" New topic
Author

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

laurie Watson
Greenhorn

Joined: Jun 23, 2011
Posts: 5
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

Joined: Aug 16, 2005
Posts: 14114
    
  16

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".


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
laurie Watson
Greenhorn

Joined: Jun 23, 2011
Posts: 5
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

Joined: Oct 13, 2005
Posts: 38472
    
  23
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

Joined: Jun 23, 2011
Posts: 5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I need to have my program take information from text file Plus my pie chart is in wrong place