I'm working on a school project and I need some help. The below works, but when I click on the "Report" button I want my data to print to a new frame. I'm not sure how to do this. Do I use a JFrame?

if(arg=="Report")
                {
                    try
                    {
                        DataInputStream readinput = new DataInputStream(new FileInputStream("poolvolumedata.txt"));
                        double inputlength;
                        double inputwidth;
                        double inputdepth;
                        double inputvolume;
                        //char tab;

                        try
                        {
                            while(true)
                            {
                                inputlength = readinput.readDouble();
                                readinput.readChar();
                                inputwidth = readinput.readDouble();
                                readinput.readChar();
                                inputdepth = readinput.readDouble();
                                readinput.readChar();
                                inputvolume = readinput.readDouble();

                                System.out.println(inputlength +  "\t" + inputwidth + "\t" +
                                                    inputdepth + "\t" + inputvolume);

Edited 3 Years Ago by Dani: Formatting fixed

Please use code tags and pay a little attention to the rules before posting.

Anyways if you just want to display the data in another window, the I would suggest you take a look at the JOptionPane

Also an alternative approach if you find the JOptionPane dialog boxes too restrictive would be, you extend from the JFrame class in your own custom class (ex. MyFrame), take the contents you want to be displayed as parameters to the constructor of this class(MyFrame), and display the contents using the appropriate controls(JLabel or JTextArea or JTextField ... whichever you wish).

This article has been dead for over six months. Start a new discussion instead.