Small Porg. help

import java.util.Random;

import javax.swing.*;

class Circle{

double radius;

finaldouble PI=3.14;

Circle(double rad){

radius=rad;

}

double area(){

return(PI*radius*radius);

}

publicstaticvoid main (String args[]){

Circle[] circleArray=new Circle[10];

Random r=new Random();

for(int lcv=0; lcv <10; ++lcv){

circleArray[lcv]=new Circle(10*r.nextDouble());

}

for(int lcv=0; lcv <10; ++lcv){

JOptionPane.showMessageDialog(null,"Radius..."+

circleArray[lcv].radius+"\nArea....."+

circleArray[lcv].area());

}

}

}

I want that 10 times the new windows not to be created ie. a concatenated output to the same window.

[1765 byte] By [riddhia] at [2007-11-26 12:36:49]
# 1
> > I want that 10 times the new windows not to be> created ie. a concatenated output to the same window.Then don't create them.Create a window with what you want on it.
zadoka at 2007-7-7 16:03:34 > top of Java-index,Java Essentials,New To Java...
# 2
You are creating a new dialog everytime thru the loop. What you should be doing is build a string, and then when the loop is finished, displaying the string in your dialog.Have a go at it.~Tim
SomeoneElsea at 2007-7-7 16:03:34 > top of Java-index,Java Essentials,New To Java...
# 3
is it not possible to display in same window? only with the help of string?
riddhia at 2007-7-7 16:03:34 > top of Java-index,Java Essentials,New To Java...
# 4

Using a JDialog, yes only by building a string, then displaying that string when you create the dialog.

If you want to create your own window, with a JTextArea component, than I guess you could create the window first, then append each result to the textarea in a loop, but that seems unneccessary to me for this program.

~Tim

SomeoneElsea at 2007-7-7 16:03:34 > top of Java-index,Java Essentials,New To Java...
# 5
could you please illustrate with code
riddhia at 2007-7-7 16:03:34 > top of Java-index,Java Essentials,New To Java...