Note that there are some explanatory texts on larger screens.

plurals
  1. POjava gui window
    primarykey
    data
    text
    <p>I wrote a java code that finds frequencies of group of input values.. this is what the last part of the output should looks like.</p> <p>Boundaries are :</p> <p>Interval [11.5 - 27.5] contains : 2 number(s)</p> <p>Interval [27.5 - 43.5] contains : 1 number(s)</p> <p>Interval [43.5 - 59.5] does NOT contain elements </p> <p>Interval [59.5 - 75.5] contains : 1 number(s)</p> <p>Interval [75.5 - 91.5] contains : 1 number(s)</p> <p>but when I tried to convert it to gui I had a little problem which is: each line of the results is displaying in a new window.</p> <p>this is the gui code:</p> <pre><code>import java.util.ArrayList; import java.util.Scanner; import javax.swing.JOptionPane; public class Frequency { private static ArrayList&lt;Integer&gt; FindNumbersInInterval(int[] array,double startInterval,double endInterval) { ArrayList&lt;Integer&gt; result = new ArrayList&lt;Integer&gt;() ; for(int v: array) { if(v &gt;= startInterval &amp;&amp; v &lt;= endInterval) { result.add(v); } } return result; } public static void main(final String args[]) { int smallest = Integer.MAX_VALUE; int largest = Integer.MIN_VALUE; int range = 0; String numberOfNumbers = JOptionPane.showInputDialog("How many numbers do you want to enter: "); int num=Integer.parseInt(numberOfNumbers); int array[]=new int[num]; for(int i=0; i&lt;array.length; i++) { String theNumbers = JOptionPane.showInputDialog("Enter the numbers now: "); array[i]=Integer.parseInt(theNumbers); { if(array[i] &lt; smallest) smallest = array[i]; if(array[i] &gt; largest) largest = array[i]; } } JOptionPane.showMessageDialog(null,"Smallest is "+smallest,"Smallest",JOptionPane.PLAIN_MESSAGE); JOptionPane.showMessageDialog(null,"Largest is "+largest,"Largest",JOptionPane.PLAIN_MESSAGE); range = largest - smallest; JOptionPane.showMessageDialog(null,"Range is "+range,"The Range",JOptionPane.PLAIN_MESSAGE); String subInterval = JOptionPane.showInputDialog("Enter the number of subinterval: "); int subnum = Integer.parseInt(subInterval); int subwid = range / subnum; JOptionPane.showMessageDialog(null,"The width of subinterval is "+subwid,"width",JOptionPane.PLAIN_MESSAGE); double boundary = smallest - .5; JOptionPane.showMessageDialog(null,"Boundaries are ","The Boundaries",JOptionPane.PLAIN_MESSAGE); while(boundary &lt; largest + .5) { double startInterval = boundary; double endInterval = boundary + subwid; ArrayList&lt;Integer&gt; numbersInInterval = FindNumbersInInterval(array, startInterval, endInterval); if(numbersInInterval.isEmpty()) JOptionPane.showMessageDialog(null,"Interval "+startInterval+" - "+endInterval+" does NOT contain elements","result",JOptionPane.PLAIN_MESSAGE); else { JOptionPane.showMessageDialog(null,"Interval "+startInterval+" - "+endInterval+" contains "+numbersInInterval.size(),"result",JOptionPane.PLAIN_MESSAGE); } boundary += subwid; } } } </code></pre> <p>So, my question is how do I make group of results come in one window?</p> <p>thnx..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload