title: JOptionPane and Graphs
body: <p>I would like to know how to give JOptionPane the ability to scroll through a histogram. I managed to get JOptionPane to display my histogram, the only problem is you can't scroll through it. The window stretches to the bottom of the screen and displays only half of the graph. </p>
  
  <p>Note: This only happens when reading large input files that contain 300+ integers between 0 and 130. The program will not recognize anything else.</p>
  
  <p>Input Values: </p>
  
  <p>54
  38
  42
  40
  34
  51
  54
  58
  61
  55
  54
  42
  40
  34
  51
  54
  54
  54
  38
  60
  42
  40
  54
  54
  54
  54
  54
  54
  54
  54
  54
  54
  54
  54
  54
  54
  54
  32
  28
  24
  18
  9
  4
  22
  31
  38
  34
  41
  32
  28
  24
  18
  31
  38
  34
  41
  32
  28
  24
  18
  31
  38
  34
  41
  32
  28
  31
  38
  35
  51
  34
  41
  56
  63
  59
  66
  48
  46
  58
  41
  56
  63
  51
  59
  48
  46
  58
  41
  56
  63
  53
  52
  58
  48
  49
  58
  41
  56
  63
  51
  52
  59
  58
  66
  63
  71
  69
  70
  72
  67
  66
  63
  71
  74
  75
  69
  73
  78
  72
  67
  63
  71
  74
  59
  56
  69
  70
  78
  72
  66
  71
  74
  69
  70
  78
  72
  67
  63
  59
  58
  57
  64
  71
  72
  67
  63
  59
  64
  71
  73
  79
  75
  78
  72
  67
  63
  59
  63
  71
  73
  75
  78
  72
  67
  63
  57
  73
  77
  75
  78
  72
  67
  71
  73
  77
  75
  78
  81
  83
  87
  84
  91
  92
  90
  84
  76
  83
  82
  89
  78
  81
  83
  87
  84
  91
  92
  90
  84
  78
  85
  82
  89
  96
  91
  78
  81
  83
  86
  82
  91
  92
  90
  84
  85
  82
  89
  92
  96
  91
  95
  97
  98
  91
  95
  97
  93
  87
  85
  94
  89
  92
  96
  93
  96
  97
  98
  98
  100
  102
  95
  97
  93
  87
  88
  89
  93
  84
  89
  92
  95
  95
  95
  97
  94
  91
  87
  84
  80
  90
  82
  80
  73
  75
  70
  74
  74
  75
  70
  66
  63
  71
  69
  70
  72
  67
  66
  63
  71
  55
  59
  53
  58
  52
  67
  63
  71
  74
  59
  56
  69
  70
  58
  62
  56
  51
  54
  49
  60
  68
  62
  67
  63
  59
  58
  57
  64
  44
  38
  42
  40
  34
  51
  54
  55
  54
  42
  40
  34
  51
  54
  54
  54
  38
  42
  31
  38
  34
  41
  32
  28
  24
  18
  31
  38
  34
  41
  32
  28
  24
  18
  31
  38
  34
  41
  32
  28
  31
  28
  35
  41
  34
  37
  26
  23
  29
  40
  45
  46
  39
  31
  40
  38
  29
  34
  36</p>
  
  <pre><code>import javax.swing.*;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  import javax.swing.JFileChooser;
  import javax.swing.JOptionPane;
  
  public class CoolWeather
  {
      static JFileChooser selecter;
      static Scanner in;
      public static void main(String[] args) throws FileNotFoundException
      {
         //Get Input File
         File inputFile;
         selecter = new JFileChooser(".");
         int status = selecter.showOpenDialog(null);
         if(status != JFileChooser.APPROVE_OPTION) 
         {
              JOptionPane.showMessageDialog(null, "Closing Program");
              System.exit(0);
         }
         inputFile = selecter.getSelectedFile();
         JOptionPane.showMessageDialog(null, "Opening: " + inputFile.getName());
         //Creates Array
         int[] temps = readData(inputFile);
         //Prints Histogram
         showMessage(temps);   
      }
      //The Following Method Creates and Populates An Array With Data
      //From The Input File
      public static int[] readData(File inputFile) throws FileNotFoundException
      {
         in = new Scanner(inputFile);
         in.useDelimiter("[^0-9/s]+");
         int[] temps = new int[131];
         int count = 0;
         int num;
         do
         {
             num = in.nextInt();
             count++;
             temps[num]++;
         } 
         while (in.hasNextInt());
         JOptionPane.showMessageDialog(null, "The Number Of Entries Read: " + count);
         return temps;    
      }
      public static void showMessage(int[] temps)
      { 
          String output = "Temp\tCount\tVisual";
          // for each array element, output a bar in histogram
          for ( int counter = 0; counter &lt; temps.length; counter++ )
          {
              if (temps[counter] &gt; 0)
              {
              output += "\n" + counter + "\t" + temps[ counter ] + "\t";
              // print bar of asterisks
              for ( int stars = 0; stars &lt; temps[ counter ]; stars++ )
                  {output += "*";}
              }
          } // end outer for
          JTextArea outputArea = new JTextArea();
          outputArea.setText( output );
          JOptionPane.showMessageDialog( null, outputArea, "CoolWeather Histogram", JOptionPane.INFORMATION_MESSAGE );
          System.exit( 0 );
      }
  }
  </code></pre>