Progress bar in java

Asked

Viewed 43 times

0

Good afternoon guys, I have a scientific initiation project in college where we work with java, in this project I created a program that performs some calculations, it displays the calculated results line by line until plotting a graph with the calculated values at the end of the process, I would now like to plot a progress bar that shows me the percentage of the calculations have been done, I searched how to plot this bar but it never works, I hope some of you can help me in this problem, thank you!

       String energy = Energia.getText();   
            String Particula= (String) comboBox.getSelectedItem();


            try {

            ProcessBuilder builder = new ProcessBuilder("C:\\Users\\Juliana Cabral\\eclipse-workspace\\Gmf1\\src\\Gmf-igor.exe", energy, Particula);
            Process process = builder.start();
            InputStream inputStream = process.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 1);
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                System.out.println(line);
            }
            inputStream.close();
            bufferedReader.close();
        } catch (Exception ioe) {
            //ioe.printStackTrace();
        }

1 answer

0

I’ll just give you an idea instead of code...

Why don’t you take the total number of lines that has in the document Number of Lines in a file in Java and the position of the current line who is being read, treating this relationship as percentage and every new percentage he adds string '#' in a bar made with System.out.println for example:

[ #########################.......................................... ]

If using any UI framework would do according to his style, for example divide the space into two colors, and every new iteration the width of one of the spaces (color) would increase...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.