JScrollPane, simple code, why doesnt it work?

i am just learning how to add scroll bars,
i do not understand why my code below doesnt work,
can u tell me how to fix it & what i have done wrong?
appreciated...
// ex 5_17 did not have a large enough display area...
// ex 5_17a changes the way it is displayed, i have added a scroll bar
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
public class Ex5_17a{
     public static void main( String args [] ){
          int terms = 1;
          double pie = 4;
          double ans = 0;
          double p = 3;
          JTextArea outputArea = new JTextArea( "15,15");
          JScrollPane scroller = new JScrollPane( outputArea );
          String result = "";
     while (terms < 40){
               terms++;
           if ((terms % 2)==0){
              pie = pie - (double)(4/p);
              ans = pie;}
           else{
              pie = pie + (double)(4/p);
           ans = pie;
           p = p+2;
           result += + pie + "   " + terms + "   " + ans + " \n";
        //outputArea.append(result);
     }//end of while terms<30
     outputArea.setText( result );
        JOptionPane.showMessageDialog(null,
           scroller,"Pie display",JOptionPane.PLAIN_MESSAGE);
     System.exit(0);
     }//end of main
}//end of class
[/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

What does "15, 15" mean?
If you want to initialize ta with number of rows and cols:
JTextArea outputArea = new JTextArea(15, 15);
To make sure you have scrolling that you want one of possibilities of using constants:
scroll = new JScrollPane(ta,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

Similar Messages

  • Why doesnt pages work on my ipad 2 and what is the alternative

    why doesnt pages work on my ipad2 and what is the alternative

    Assuming that your iPad isn't on iOS 5 (your current version is shown in Settings > General > About > Version on the iPad), then to update to it you first need iTunes 10.5 on your computer - if you don't have itunes 10.5 then you can download it from here http://www.apple.com/itunes/download/.
    To update your iPad connect it to your computer's iTunes and select it on the left-hand side of iTunes. Then, if the update isn't automatically detected and you are prompted to download it, on the right-hand side on the Summary tab click the Check For Updates button

  • Table cell scroll bar overflow- why doesnt it work?

    Hi everyone.
    Ok, im have an existing document/site:
    http://www.helenbwilson.com/helen-portfolio-1.html
    I want the table cell in the left to have a scroll bar (only
    with the height part). I want the "block" of the images to have a
    height of 400px. Now, I have tried to do this, and for the most
    part got it to work-in another document:
    http://www.helenbwilson.com/CSS-test-01.html
    I am trying to replicate, but I have absolutely no idea why
    its not working now.
    I applied a css style and I want the same type of scroll, so
    when there are more images, it can have a scroll bar.
    Can anyone tell me what Im doing wrong? If I am not being
    clear, please let me know.
    Any info would be appreciated.
    Thanks
    -psy

    I think you mean something like this:
    Put this in your head:
    <style type="text/css">
    <!--
    .imageBlock {
    display: block;
    float: left;
    height: 400px;
    width: 250px;
    overflow: auto;
    background-color: #FF0000;
    -->
    </style>
    put this in your body:
    <div class="imageBlock">
    </div>
    If the table or other content you place inside your
    'imageBlock' div, is higher than 400 px, you'll get a vertical
    scrollbar.

  • Why doesnt it work

    ive tried everything why wont it work, it just print back in the order i put it in. I'm trying to sort alphabetically.
    public class Sortstringskinda
        public static void sort(String names[])             
            String temp;                                   
            for(int i = 0; i < names.length - 1; i++)       
                for(int ii = 0; ii > names.length - 1; ii++)
                    if(names[ii].compareToIgnoreCase(names[ii+1])<0)              
                        temp = names[ii];                   
                        names[ii] = names[ii+1];             
                        names[ii+1] = temp;                 
        public static void main(String[] args)
             //declares an array to be sorted
             String names[] = {" Chen"," Lin"," Huang"," Zhu"," Zhang"," Wu","Wang"," Cai"," Sato"," Suzuki"," Takahashi"};
            // for(int i = 0; i < names.length; i++)     
            //     System.out.println(names);
    sort(names);
    System.out.println("\nAfter sort():\n");
    for(int i = 0; i < names.length; i++)
    System.out.println(names[i]);

    public class Sortstringskinda
        public static void sort(String names[])             
            String temp;
            for(int i = 0; i < names.length; i++ )       
                for(int ii = 0 ; ii < names.length-1; ii++)
                    if(names.compareToIgnoreCase(names[ii]) < 0) /*choose order*/
              temp = names[ii];
    names[ii] = names[i];
    names[i] = temp;
    public static void main(String[] args)
    //declares an array to be sorted
    String names[] = {"Chen","Lin","Huang","Zhu","Zhang","Wu","Wang","Cai","Sato","Suzuki","Takahashi"};
    // for(int i = 0; i < names.length; i++)
    //System.out.println(g.compareToIgnoreCase(h));
    sort(names);
    System.out.println("\nAfter sort():\n");
    for(int i = 0; i < names.length; i++)
    System.out.println(names[i]);

  • How to install windows on a mac... why doesnt it work?!!!!

    Ok hey ya,
    I got an amazing problem... its just making me confused and at ** at the same time,... sry for bad language...
    I actually never tried this.. to let windows run on a mac! Me myself i got a macbook pro 15 inch... ive done mostly evertything which is needed to get the laptop ready to reboot on Windows. Only one thing just doenst want to work for me! When you download the Boot Camp Assitent to make another partition for Windows System, it tells me to update my firmware! So, i went downloading the whole thing and started the Boot Campt Assitent again. But then it told me *update the newest Firmware on you computer*.
    So i left the program again, looking for another update. I downloadt another one. Tried again, missed again. Everytime i want to open the Boot camp assitent. It tells me the same thing every single time *Update.... befor you can use this program!* why? it just did that and i donnot understand why its not working for me?!!!
    might you guys help me out plz?
    Regards
    Hush
    MacBook Pro 2.0 Ghz   Mac OS X (10.4.7)   Just amazing

    Hi Hush,
    Did you download and install THIS firmware update?
    http://www.apple.com/support/downloads/macbookproearly2006firmwareupdate101.html
    This is the firmware needed to install Windows XP.

  • Why doesnt this work, its so simple

    The following piece of code I guess should print "THEY ARE EQUAL" but it doesnt. I dont know why???????????? anybody help.
    String check = new String("new���".getBytes("iso-8859-1"), "iso-8859-1");
    for(int i =0 ; i< check.length(); i++)
    if(check.charAt(i)=='���') System.out.println("THEY ARE EQUAL");
    }

    You aren't comparing whether the two strings contain
    the same data, you are comparing whether the two
    references point to the same objects. Try it again
    using the .equals() method to compare the contents of
    the two strings instead of using ==.For the first time in my life have I seen DrClap err. So he is human too. amit234 is comparing characters and not Strings
    I found the solution to your problem your the corresponding line in your code with this one and it would work
    if(check.charAt(i)=='\u20AC') System.out.println("THEY ARE EQUAL");
    happy coding

  • Problem with WindowAdapter, why doesnt this work ?

    Hi
    I have created a source file with the following code:
    import java.awt.* ;
    import java.awt.event.* ;
    import javax.swing.* ;
    public class EventDemo3 extends JFrame
         EventDemo3()
              // Setter tittel, st�rrelse og gj�r det synlig
              setTitle("EventDemo3 - lukking av vindu") ;
              this.addWindowListener(new WindowAdapter() {
                   public void windowClosed(WindowEvent e)
                        System.exit(0) ;
              setSize(300, 300) ;
              setVisible(true) ;
         public static void main(String[] args)
              new EventDemo3() ;
    }It compiles and runs, but when i close the window the JVM is still running and i cant figure out why, does someone know why this doesnt work ?
    Message was edited by:
    icebyte

    Perhaps you want this instead:
    import java.awt.* ;
    import java.awt.event.* ;
    import javax.swing.* ;
    public class EventDemo3 extends JFrame
         EventDemo3()
              // Setter tittel, st�rrelse og gj�r det synlig
              setTitle("EventDemo3 - lukking av vindu") ;
              this.addWindowListener(new WindowAdapter() {
                            @Override
                   public void windowClosing(WindowEvent e)
                        System.exit(0) ;
              setSize(300, 300) ;
              setVisible(true) ;
         public static void main(String[] args)
              new EventDemo3() ;
    }

  • Why doesnt iMessage work here?? It doesnt work at all.

    IMessage doesnt work with me! What can i do to fix it? Help please;(

    Im getting nothing...i cant send or recive any message,i cant use that feature.When i go to the Sitting it says waiting for activation!!!! And its been more than 2months

  • T61 does it have a mic if so why doesnt it work ?????????

    Dear Gurus,
    Hi. I have been a proud buyer of the lenovo T61 machine for almost a year now and I am proud my machine is still few hours old which was used only for the two problem resolutions(first it was restoration issues and then battery issues).
    Finally I got replacement battery now I felt that my machoine doesnt have mic. I did try to look for it and then after a long serach on the internet did find out that my machine did have a mic but its not working. 
    Kindly lenovo lovers plz help me out how to make this work. At times I feel bad that I bought the most reliable name (THINKPADS) in the notebook industry or at times i felel that may be I was the unlucky ones. I need urgent help as I am about to go on my business trip and without a mic i will be stuck.
    Thanks in advance waiting for a reply soon.  
    THINKPADT61 / 7662CTO / T7500 / 100GB 7200RPM / 2GB RAM / 14.1 WIDE SCREEN / NVIDIA 140MS / 4965AGN / BT / WINDOWS XP
    Solved!
    Go to Solution.

    You did not mentioned anything about the driver update in you previous post. Anyway, I you suspect that the issue is cause by the driver then you shoud go back to the previous dirver. I do not know about Windows XP but you can do that in Vista from device manager. Other way to get the driver (or the previous version of it) is to go to the Lenovo Support & Downloads page (you should have the linkg in your browser preferences).
    Finally, if nothing works then you still have the option to call Lenovo.
    Hope this helps.
    ThinkPad T500 2242-CTO P8600 / 4GB RAM / WSXGA+ / HDD Fujitsu 7200rpm 1TB / 6 Cell Sony / Windows 8 Pro 64-bit
    ThinkPad Tablet 2
    ThinkPad X61s 7669-3KG Windows 7 Home Premium 32-bit

  • Why doesnt foxyspider work with 26.0 after auto update

    I was using foxyspider successfully for several months until firefox auto updated to version 26. After the update it will no longer download. All other functions work but files will not be saved. A new page will open and thumbnails are visible, but when the option to save files manually or select all files is chosen and a location is selected to download, nothing happens. Again, it worked properly with the previous version of firefox.. I have contacted the developer of foxyspider twice but have received no reply. If it does not work anymore, I will have to give it a poor rating. Before firefox 26.0 foxy spider was 10 of 10 but no it is a big zero.

    Hello rickster_too,
    Thank you for contacting Mozilla Support. I'm sorry that the Foxyspider developer has not gotten back to you.
    Have you tried uninstalling and reinstalling the extension?
    It looks like the developer isn't very active on his social media channels, but you might try reaching out there.
    https://addons.mozilla.org/en-US/firefox/addon/foxyspider/
    And there are a number of other addons that you can try that will work with FF26. Here's a list of similar addons that Mashable put together.
    http://mashable.com/2007/07/31/firefox-downloads/
    Please let us know if this helps.
    Cheers,
    Patrick

  • Why doesnt this work??

    Hi All,
    Im tryin to design a website to take an image out of the database and display it on the jsp page.
    I call the image using:
    <img src="ImageServlet?id=3" width="250" height="250" align="top">
    This calls the servlet that displays the image. The first time i call this the image is displayed. I dont store the image in the session.
    My problem is when i click a link to another page and then come back to the original page the image doesnt display. If i refresh the page it wont display. It will display when i manually right click the image and show the picture.
    What could be the cause of this. The image is their it just wont display the second time the page is called.
    Thanks for any help in advance.

    I changed the way the servlet handled the image and got it to print any error instead of throwing them. This is what is coming up.
    java.io.IOException: Stream closed
    at java.io.BufferedInputStream.ensureOpen(BufferedInputStream.java:120)
    at java.io.BufferedInputStream.available(BufferedInputStream.java:336)
    at ImageServlet.doGet(ImageServlet.java:36)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:260)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
    2396)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
    rValve.java:170)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22
    3)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :405)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
    ssConnection(Http11Protocol.java:380)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
    :508)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
    ool.java:533)
    at java.lang.Thread.run(Thread.java:536)
    This is the servlet that generates the error.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import ProductDetails.*;
    import java.io.*;
    import java.util.*;
    import java.awt.image.*;
    public class ImageServlet extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    public void destroy() {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    try
    HttpSession session = request.getSession(false);
    Product p = (Product) session.getAttribute("prod"+request.getParameter("id")+"");
    int i = p.getID();
    //if( i == Integer.parseInt(request.getParameter("id")) )
    InputStream in = p.getImage();
    response.setContentType("image/jpg"); // or whatever type of file it is.
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Expires", "0");
    response.setHeader("Pragma", "No-cache");
    response.addHeader("Cache-control", "no-store"); // tell proxy not to cache
    response.addHeader("Cache-control", "max-age=0"); // stale right away
    ServletOutputStream sout = response.getOutputStream();
    int c;
    int b = in.available();
    while((c = in.read()) != -1)
    sout.write(c);
    int imad = 0;
    System.out.println("Image called. "+ imad + " Available: " + b);
    in.close();
    in = null;
    sout.flush();
    sout.close();
    return;
    catch (Exception e)
    e.printStackTrace();
    throw new ServletException(e);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    doGet(request, response);
    Product stores an Inputstream that is gotten from the database.

  • Map map = new HashMap(); -why doesnt this work in jdk 1.8.1

    Hi there,
    I'm trying to use a hashmap like this below:
    Map map = new HashMap();
    map.put("Carrots", new Integer(12));
    map.put("Potatoes", new Integer(30));
    map.put("Onions", new Integer(15));
    map.put("Apples", new Integer(40));
    map.put("Cherries", new Integer(300));
    the HashMap() does not exist in my API for some reason.
    Can anyone tell me why this may be?
    i'm using the hashmap with a stringtokenizer to search a text file line by line and increment how many times each keyword occurs.Sound efficient way of doing it?
    cheers,

    do you mean jdk 1.1.8?
    Map and the other Collections API were added in JDK 1.2. for JDK < 1.2, use Hashtable instead.

  • N73 why doesnt it WORK?

    I have been buying Nokia for 8 years, and have been very happy especailly with my old 6810. I bought the new N73 from Tre last october and thats when my troubles have started:-
    1. Joystick fell off
    2. During a call the phone locks and resets itself?
    3. If i want to silence an incoming call, the phones switches off.
    4. It take 15 minutes to view my photo gallery.
    5. The screen has dust or something in the display.
    I never write these message but i really feel that Nokia should know the products problems. When i leave my phone for repair at your repair center it take 2 weeks and NO loan phone.
    My phone is running the latest firmware 6.83.14.1 and i regular use PC suite to download pictures to keep space free on my memory card. Please could Nokia please swap this phone i give me one that works?

    To --> swedish_bob
    u have the oldest firmware on ur n73... try updating to the latest firmware...
    Also people who bought N73 in January 2007 - Until Present the joystick are better than the (1st batch) back in october n stuff ....
    Just send it back to Nokia & they will give u a better & stable N73
    If you find my post useful then click on
    Kudos!Nokia N96 (v20.050 / RM-247)
    www.shaysoft.net | Competitions!

  • Why doesnt itunes work  after downloading ios7?

    My phone turns off out of no where also. its really annoying.

    Read through this article and see if you can find the solution:
    http://docs.info.apple.com/article.html?artnum=61711

  • Why doesnt java work with firefox,i cannot open certain sites

    ive been trying to go online auction and it will not bring up the auction

    The message about CVE-2009-3555 is meant for webmasters to make them aware that they need to fix their servers.<br />
    Firefox 3.6 versions can detect such a misconfiguration and displays a warning in the "Tools > Error Console".<br />
    * http://wiki.mozilla.org/Security:Renegotiation
    See:
    * http://kb.mozillazine.org/Firefox_crashes
    * [[Firefox crashes]]
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]

Maybe you are looking for

  • Is it time to upgrade my Macbook's RAM?

    I have a Macbook 2nd generation (2 GHz, 1 GB memory). When I open Photoshop CS2 or Illustrator CS2, it tells me that my memory is running low. Also when I have several programs open, such as iTunes, Safari, and iChat, they seem to run slower. ALSO I'

  • [SOLVED] i'm trying to mount an iso

    hi, im trying to mount a cd image, but am getting the following error, [root@arch image]# mount -t iso9660 -o loop image.iso cd1 mount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error In som

  • SQ01 (ABC Analysis)

    Hi All For a query in SQ01,output format - ABC analysis. I find Key Figure & Features having a default value. I would like to know how can i make this field as selectable, eg: Key Figure at the moment is defaulted to Plnd Dlvy Time, say i want to hav

  • The backend of system SAP_R3_UWL is not configured for optimized delta pull

    Hi All, I used the below to configure the Enabling Delta Pull Mechanism in UWL. http://help.sap.com/saphelp_nw04s/helpdata/en/eb/101fa0a53244deb955f6f91929e400/frameset.htm uwl_service user created and assigened role SAP_BC_UWL_SERVICE with the help

  • Automatically find home wi-fi at login

    "Somehow" for the past week my Network System Preferences aren't automatically finding my home w-fi so I have to do it manually each time that I start up. I tried to figure out which setting needs to be changed or changed back to how it was. I have m