Displaying progress with JTextArea

Hi,
As newbie, I'm trying to test a concept to see if I can get the new data be appended and displayed immediately in a JTextArea. I wrote a little application that display the number as it loops through in actionPermformed interface. I put a short pause so I can see the number being refreshed into JtextArea. However, what I get is the application process all the loop and repaint the text area with all numbers. As a result, I don't the get progressing paint effect as the application loop through in for loop. What method I should use to achieve this effect? Here is the code I use.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Loop extends JFrame implements ActionListener{
      JTextArea taNum = null;
      JButton btnLoop = null;
      JTextField tfNum = null;
      JScrollPane jspNum= null;
      public Loop (){
        setSize (100,200);
        setLocationRelativeTo(null);
        Container pane = getContentPane();
        pane.setLayout (new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        c.anchor = GridBagConstraints.WEST;
        tfNum = new JTextField(10);
        c.gridx=0;
        c.gridy=0;
        pane.add(tfNum,c);
        btnLoop = new JButton ("Loop");
        btnLoop.addActionListener(this);
        c.gridx=1;
        c.gridy=0;
        pane.add(btnLoop,c);
        taNum = new JTextArea("Start",5,20);
        jspNum = new JScrollPane(taNum);
        c.gridx=0;
        c.gridy=2;
        c.gridwidth=2;
        c.gridheight=2;
        c.ipady=20;
        pane.add(jspNum,c);
        pack();
        setVisible(true);           
      public void actionPerformed (ActionEvent e){
       try{ 
         for (int i =0;i<Integer.parseInt(tfNum.getText());i++){
           taNum.append(Integer.toString(i)+'\n');
           taNum.setCaretPosition(taNum.getDocument().getLength());
           repaint();
           Thread.sleep(500);
        } catch (InterruptedException ex){
          ex.printStackTrace();
      public static void main (String [] argv){
          Loop l = new Loop();
/*************************************/Thank in advance.
Kim
Edited by: kimtitu on Oct 1, 2010 2:03 PM

1) Read the "Welcome to the new home" posting at the top of the forum for information on the proper way to add code to a posting
2) Swing related questions should be posted in the Swing forum which is found under "Java Desktop" from the forums home page.
3) Read the section from the Swing tutorial on [url http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html]Concurrency for more information about why it doesn't work and for one possible solution.

Similar Messages

  • Display Progress Indicator in the Run Time

    Hi All,
    How do display Progress Indicator in the Run Time for a JSF Page using ADF components?
    Regards
    Santosh

    I have similar problem.
    Basically my page do search in the database which takes some time. so when search starts I would like to display the progress indicator or some thing which will show some processging is going on in background. Once it completes the background processing, the same page displays the result. At this time I want to hide the progress indicator.
    Is there any way to do this. I am using EA17 with JDev.

  • Using Apple Pay no longer displays "pay with touch id"

    When using apple pay, my iphone used to display "pay with touch id" and when the transaction was approved, the screen would change to say "done" and a green check mark would appear. Last week, I had to take my phone back to factory default and restore apps, music and photos. Now when using Apple Pay, the screen is black, and neither the "pay with touch id" (to indicate that the transaction is in progress) nor the "done" displays, and I cannot tell if the transaction is going through our not.
    Does anyone have any ideas what's going on?
    Thank you.

    To be functional, Apple Pay must see the chip it uses, which only exists in the iPhone 6/6+.  Touch sensor is a security feature for the iphone 5s itself and is independent of Apple Pay.

  • How to use old 2005 cinema display (20'') with MacBook Air (mid-2009)

    My old 20'' cinema display (2005) has three ports coming out of its power box (single-port dvi, usb, firewire).  Is it possible to use this display with my newer MacBook Air (mid-2009) ? If so, what kind of connector do I need?  Thank you very much for your help.

    To use my old Cinema display (2005) with my old PowerMac G5 (2005) I had to plug in all three ports (DVI, usb and firewire) into the desktop.  Can I really use the display just with the DVI output plugged into my MacBook Air mini-Display Port ? 

  • Display Issues with mini (Mid 2010) and LG L246WP

    I recently purchased a new mini (Mid 2010 base model) and planned to use it with my 24" LG L246WP monitor, which is about 3 years old. The monitor has VGA, component, and HDMI inputs.
    I used an HDMI-to-HDMI cable to connect the mini directly to the monitor, and the output is completely messed up. The mini recognized the monitor (titling the System Preferences > Display dialog with 'L246WP') and set it to the monitor's native resolution of 1920x1200, but on the monitor the image is cropped to what looks like a 4:3 aspect ratio and with part of the image shifted up and left so I cannot view the top menu bar or the left hand side of the desktop. The monitor's on-screen display shows 1080p in this mode.
    The Display dialog also gives me an option for 1080p. I can select this and use the Underscan slider to resize the desktop output to fit on the screen, but it is still shifted left and must be resized smaller than the available display space (plus the total image is only 1080 pixels, not using the monitor's full native screen). In this mode, 1080p also shows on the monitor's on-screen display.
    I tried 1024x768 to see if I could get a properly-positioned image, but the desktop was shifted just like in the 1920x1200 case and the monitor's on-screen display status still reported 1080p.
    The monitor has a menu setting under an HDMI heading with "Video" and "PC" options, but changing this selection does not make a difference.
    Since the monitor came out before HDMI was as widespread as it is today, it came with a DVI-to-HDMI cable, so I also tried using that cable with the HDMI-to-DVI adapter that came with the mini, but this did not make a difference either.
    To prove it wasn't the HDMI cable, I connected the mini to my Samsung 6300 series 40" LED HDTV and with some tweaking of the Underscan slider the displayed image filled the screen perfectly.
    I've searched the Internet and various forum threads (i.e. http://hardforum.com/showthread.php?t=1167222&page=63) seem to indicate this monitor can send a corrupted EDID that causes issues, especially with nVidia graphics drivers. On Windows you can use registry or driver hacks to override the EDID with the correct values, but on OS X this doesn't seem possible (I was hoping for a Terminal one-liner but it seems this doesn't exist). I have seen some mentions of the shareware SwitchResX (http://www.madrau.com), which looks like it gives you the option to override resolution settings, but I haven't tried this yet.
    It also appears to me that the monitor is always interpreting the signal (or the mini is always sending the signal) as 1080p, even if I've set 1920x1200 in the Display dialog. I don't know if this is a defect in the monitor where it always assumes the HDMI input is a 1080p source (previous I used it with an Xbox 360 with no issues but that was 1080p HDMI), or if is a bug in the graphics drivers (or at least a lack of flexibility / miscommunication to the user trying to handle a corrupt EDID).
    I asked my local Genius Bar for advice today (without bringing any hardware in) but was not told anything I didn't already know.
    I'm trying to determine the best way to work through this issue. *My questions are:*
    Would it make any difference if I used a Mini DisplayPort-to-DVI adapter (and then my DVI-to-HDMI cable to the monitor's HDMI input)?
    What about a Mini DisplayPort-to-VGA adapter? In the past I used a 12" Powerbook (via a mini-DVI-to-VGA adapter) with this monitor and had no display issues like this, but I'd prefer to stick with a digital connection on my brand new mini.
    Is SwitchResX the only practical way in OS X to override a corrupt EDID and force the mini to output a certain resolution?
    Besides the various adapters and SwitchResX, is there anything else I should try before buying a new monitor?

    Hello EPWilson4984.
    I have been experiencing the same issues you described. Connecting my brand new Mac Mini to my Westinghouse 24”monitor (L2410NM,  1920x1200 pixel resolution) produces a very fuzzy and washed out image quality. The Mac recognizes the monitor and applies the right resolution (1920x1200), but it looks just awful. The EDID info is definitely not right.
    Now, I tried your suggestion (DVI-to-HDMI), and similar suggestions from other threads, but nothing works. Nothing seems to work at all.
    The main input for the monitor is HDMI, so whatever cable I use, in the end always has to connect to the monitor via HDMI. I tried all these combinations with zero success:
    Mac mini -> HDMI cable -> monitor (result: fuzzy and blurry image)
    Mac mini -> displayport –HDMI adapter-> HDMI cable -> monitor (result: fuzzy and blurry image)
    Mac mini  -> displayport –DVI adapter-> DVI-to-HDMI cable -> monitor (result: it gives me a blank screen, no image at all)
    I’m running out of options. Don’t know what to do. The 24” monitor produces beautiful, crisp images when hooked to my Windows 7 PC. It looks horrible when connected to my brand new Mac Mini.
    Any alternatives you may have come across? Please let me know, thank you.

  • Studio Display 21" with Mac Mini?

    I am considering getting a Mac Mini as an economical upgrade to my B/W G3 system but I want to make sire that my monitor is going to work with it. I have the origingal blue and white 21" Studio Display. the System Profiler says this......
    Displays:
    Studio Display 21:
    Display Type: CRT
    Resolution: 1152 x 870 @ 75 Hz
    Depth: 32-bit Color
    Core Image: Not Supported
    Main Display: Yes
    Mirror: Off
    Online: Yes
    Quartz Extreme: Not Supported
    Will this display work with a new Mac Mini? I really do not have the $ right now to get a new Monitor and this one works great anyway. I am also wondering how my current software,,,,,,, Photoshop,Indesign etc. will work with the new Intel Macs?
    THanks for any input
    MyShunshyn

    Can't help on the screen much - believe you need to get an adapter, as the previous post indicated. You might check in the Apple dislay area at http://discussions.apple.com/category.jspa?categoryID=111
    Regarding your applications, as long as you're not running under OS 9 or earlier, your applications will run on the Intel mini under Rosetta emulation. Universal applications are those that have been modified to run on both the PPC and Intel macs, and they run natively. Those applications that have not been made universal run under Rosetta emulation. Photoshop is an example of an application that has not been made universal yet (supposed to happen this year with Photoshop CS3). Running under emulation does extract a performance penalty, of up to 50%, versus running in native universal mode.
    If you have applications running under OS9 or in the OS X classic environment, you'll need to upgrade to an OS X version in order to run on the Intel-based mini, and you may find there are Universal versions of your software, which would be even better.

  • Is there a way to use the iMac's display mode with a Mac mini with out logging in first on the Mac mini

    Is there a way to use the iMac's display mode with a Mac mini with out logging in first on the Mac mini (late2014)
    im currently useing my Mac mini as a portable computer, I take it to the university and use the iMacs there as a monitor but before I can do that I have to log in to my Mac mini first which means doing it blind
    is there a way to put the IMacs into display mode with out logging into my Mac mini first
    or is there a portable monitor that I can use that will not require me to login first

    This
    Target Display Mode: Frequently Asked Questions (FAQ) - Apple Support
    says:
    How do I enable TDM?
    Make sure both computers are turned on and awake. 
    Connect a male-to-male Mini DisplayPort or ThunderBolt cable to each computer.
    Press Command-F2 on the keyboard of the iMac being used as a display to enable TDM.
    Note: In Keyboard System Preferences, if the checkbox is enabled for "Use all F1, F2, etc. keys as standard functions keys," the key combination changes to Command-Fn-F2.
    How do I exit TDM?
    To leave TDM, press Command-F2 on the keyboard of the iMac that is in TDM. You can also exit TDM if you shutdown or sleep either computer or detach the cable.
    Can I use a third-party keyboard or older Apple keyboard to enable TDM?
    Some older Apple keyboards and keyboards not made by Apple may not allow Command-F2 to toggle display modes. You should use an aluminum wired or wireless Apple keyboard to toggle TDM on and

  • Cinema Display (clear) with DVI/ADC box doesn't work with MacBook Pro

    Cinema Display (clear) with DVI/ADC box doesn't work with MacBook Pro when plugged in with a dvi to mini dvi cable. Any ideas what to do to make it work? I lugged the 23" 2500 miles into the wilderness and I need help

    Okay, here's an update: the DVI to ADC adapter does work with the Apple displays that I have tried, but it won't work with the Formac. I have tried multiple time to contact them, but to no avail... they don't even respond to threats of posting my opinion of them, which is this:
    DON'T BUY ANYTHING FROM FORMAC! They make quality products, but their customer service is a big time joke! They won't take care of you.

  • To Display Output in Grid ALV with change of some field display total with

    Hi Masters,
    I m working on ALV in which  i have to display output with the following format.
    Header
    "Some String"                                                             date/time                                                                               
    User:XYZ01       page 1 
    Line
    1st field    2nd    3rd     4th       5th   6th    7th   8th   9th  10th field
    x               y       z        A        B     C       D     E      F       G
    BLANK..............................................................................                            
                          "total 3rd+4TH"           P        Q     R      S        T       
    same thing for every change of 4th field .
    So the problem is with inserting the line with string "Total of 3rd+4th" in the output .
    Can Anyone help me out?
    Thanks ,
    Varlani Amit

    Hi,
    Use control-break statement ON-CHANGE for the 4th field, and do the changes.
    regards,
    sri

  • How can i Display images with may own table

    Hi
    I want display images with my own table. How can I use in this query.
    SELECT    '<a href="#" onclick="javascript:'
           || 'getImageHeight(''my_img'
           || '#ROWNUM#'');javascript:redirect'
           || '(''f?p=&APP_ID.:212'
           || ':&SESSION.:DISPLAY:NO::P212_IMAGE_ID:'
           || ID
           || ''');">'
           || '<img src="#IMAGE_PREFIX#edit.gif" '
           || 'alt="Edit"></a>' ID,
              '<img id="my_img'
           || '#ROWNUM#" src="#WORKSPACE_IMAGES#'
           || filename
           || '"/>' image
      FROM wwv_flow_filesThanks
    Nr
    Edited by: user10966033 on Sep 28, 2009 1:41 PM

    You don't use #workspace_images# since that is for STATIC files, not images in a table..
    see this thread for help: Re: Display image from blob
    Thank you,
    Tony Miller
    Webster, TX

  • Is there a way to track "pages viewed" progress with PDF's?

    Is there a way to track "pages viewed" progress with PDF's?
    Example: Student downloads a PDF from school portal -- Teacher can track who downloaded PDF, when and how many pages were view (where student stopped)? Similar to Flexpaper?

    The only other way I can come up with at the moment is by submitting the data via a URL to your server... The user will still have to allow the URL to be opened, though.

  • Display Problem with my Mac Pro and LG Flatron Wide Monitor in Mountain Lion

    After upgrading to Mountain Lion, my Mac Pro has display problems with my LG Flatron display.  The image is displayed with a black bar on the right and on the bottom.  And the left side of the content is not visible.  I tried every resolution available in the Display System Preferences, they are different in terms of how big the black bars are, and what part is not visible, but none of them are correct.  I held down the option key to try to detect displays or switch to resolutions that are not normally available.  When I restart the image is lined up with the display, but if the display ever goes to sleep or gets turned off, the image reverts to being off center, and the only way I can get it back is to restart...  The interesting thing is that this monitor works fine with the same machine if I reboot using BootCamp into Windows 7.  The Monitor also works fine, connecting the same connector to a Mac Mini, although that mac mini is running 10.6 and not Mountain Lion.  I've reset the SMC and restarted countless times, I don't see any other levers to pull or things to try...

    That card is for a PC it may not give you Startup and Option-Boot screens.
    The 7950 "Mac Edition" card has a very distinctive look:
    http://www.sapphiretech.com/presentation/product/product_index.aspx?cid=1&gid=3& sgid=1157&pid=1777&psn=&leg=0&lid=1

  • How to get/display  time with minutes in a test item

    Dear experts,
    Forms [32 Bit] Version 10.1.2.0.2 (Production)
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Oracle Toolkit Version 10.1.2.0.2 (Production)
    PL/SQL Version 10.1.0.4.2 (Production)I've the following requirements.
    In my form, there are three text items and one save button.
    Text items named as
    No_of_days --> Number data type
    (user will enter number of days)
    hours_limit --> Char data type with format mask (HH:MI);
    (user will enter hours with minutes)
    Upto_date_time --> date data type;
    this field calculated as (No_of_days+hours_limit+sysdate)
    User will enter No_of_days or hours_limit:
    Based on the values I've to calculate Upto_date_time
    Here is the problem:
    1) If user doesn't enter hours_limit I want to show default time as " 04:00 PM"
    2) If user enter hours_limit field we should allow them to enter in the following format
    "HH24:MI" format;
    what whould be suitable data type for hours_limit field..
    I tried with char and i've set the format mask as ,
    set_item_property('BLOCK3.hours_limit',format_mask,'HH:MI');
    But I'm geeting the error
    "FRM-50027:Invalid format mask for given datatype"
    Please help to solve this problem,
    Regards,
    Karthi

    Hi vansul ,
    set_item_property('BLOCK3.hours_limit',format_mask,'HH:MI');
    Format mast is only allowed to date data type fields.If i set the hours_limit item's data type as date , I'm getting the error message "ORA-01843:Not a valid month"..
    How could i make this field only getting or display time with minutes?
    Regards,
    Karthi

  • Not all chinese characters display correctly with non-embedded text

    Hi all,
      I've updated to the last beta 2 of Flash Player 10.1 (10,1,51,66) and compiled this simple Flex application to illustrate the fact that not all chinese characters can be displayed correctly with non-embedded text (device font).
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/halo"
                   minWidth="1024" minHeight="768"
                   creationComplete="resourceManager.localeChain = ['zh_CN'];"
                   layout="{new VerticalLayout()}">           
        <fx:Script>
            <![CDATA[
                import spark.layouts.VerticalLayout;
            ]]>
        </fx:Script>
        <s:Label text="伜-伞伟传伡伢伣伤伥伦伧伨伩伪伫伬伭-伝">
        </s:Label>
        <mx:Label text="伜-伞伟传伡伢伣伤伥伦伧伨伩伪伫伬伭-伝"/>       
    </s:Application>
      Notice that characters from the Unicode range 0x4F1E .. 0x4А2D are not displayed within <s:Label> component that uses Flash Text Engine (FTE) by default to display the text, but at the same time those characters display just fine within older <mx:Label> component that relies on flash.text.TextField instance to render the text.

        OK, did not know that "Arial Unicode MS" font is only distributed with Microsoft Office, was looking into relying on this font in case if "simsun.ttc" font is not available at the user's system, by using the following:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   minWidth="1024" minHeight="768"
                   creationComplete="resourceManager.localeChain = ['zh_CN']"
                   layout="{new VerticalLayout()}">               
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/halo";
            s|Label {
                fontFamily: "Arial Unicode MS, SimSun, Arial";            
        </fx:Style>   
        <fx:Script>
            <![CDATA[
                import spark.layouts.VerticalLayout;
            ]]>
        </fx:Script>
        <s:Label id="sparkLabel" text="伜-伞伟传伡伢伣伤伥伦伧伨伩伪伫伬伭-伝"/>   
    </s:Application>  
    Tough decision ahead, but accordingly to  the survey at codestyle.org (2000 participants from 2007 year and onwards), Arial Unicode MS is present at 62.53%% system surveyed.
    ps
       My current install of Windows XP already includes the install of Microsoft Office 2007 and I've also enabled/disabled the support of East Asian languages, thus the content of  my "fonts" folder differs now significantly from "clean" Windows XP install version.
    Nevertheless I found the page with comprehensive lists of standard fonts installed with different releases of Windows that looks viable here:  http://www.kayskreations.net/fonts/fonttb.html

  • I'm new to Photoshop Elements and just getting started.  While in the organizer I have one group of photos up to learn with and now it says Edit in Progress with a padlock icon.  How can I remove this so that the photos will be restored to normal?

    I'm new to Photoshop Elements and just getting started.  While in the organizer I have one group of photos up to learn with and now it says Edit in Progress with a padlock icon.  How can I remove this so that the photos will be restored to normal?

    Go back to the editor and close the photo there.

Maybe you are looking for

  • Data Federator data source not available causes Universe Connection error

    I created a Data Federator project that connects to 20 servers across US and Canada.  All data sources are SQL Server 2005.  The DF project maps 40 source objects into 4 target objects.  I created a universe based on the DF project and we have been q

  • Bridge not opening

    I started having this problem on PS CS3 but have recently upgraded to CS4. When I open bridge by itself or through PS, nothing opens at all and I get the box saying it has encountered a problem and needs to close. What could be causing that? Also re-

  • Can I import MTS files into Final Cut Express?

    It seems like FCE only reads MOV and MP4 files, and sometimes it doesn't even read those for me. Is there no easy way to import and edit MTS video files?

  • Centered flash site with no margins

    I was wondering if any one could help me in "coding" my site to have my flash page be centered and have NO margins.... I know Kirupa.com had a code on his site in regards to some code to be placed in the "head" tag of the .html "page" but it has sinc

  • Reuse Variable In Packages

    I have a scenario where I need to reuse the variable in several packages without refreshing it. For example I have package 1, 2 and 3. I have defined a variable var_timestamp with latest value and declare this variable in package 3, I have generated