Output not appearing when using SwingWorker?

Hi guys,
I'm desperate here. Any help would be great.
I'm using SwingWorker to append info into a Text Area, but when I run the code, nothing happens in the TextArea. Here's the code
public class RLGUIFrame extends javax.swing.JFrame implements ActionListener{
    private final GridBagConstraints constraints;
    JTextArea movementText;
    private final Border border =
        BorderFactory.createLoweredBevelBorder();
    private final JButton startButton, stopButton;
    private RobotTask robTask;
     public static final int GRID_SIZE=10;
     public static final int NUMBER_OF_TIMES=1000;
    private JTextArea makeText() {
        JTextArea t = new JTextArea();
        t.setEditable(false);
        t.setAlignmentX(RIGHT_ALIGNMENT);
        t.setBorder(border);
        getContentPane().add(t, constraints);
        return t;
    private JButton makeButton(String caption) {
        JButton b = new JButton(caption);
        b.setActionCommand(caption);
        b.addActionListener(this);
        getContentPane().add(b, constraints);
        return b;
    public RLGUIFrame() {
        super("RL");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Make text boxes
        getContentPane().setLayout(new GridBagLayout());
        constraints = new GridBagConstraints();
        constraints.insets = new Insets(3, 10, 3, 10);
        movementText = makeText();
        //Make buttons
        startButton = makeButton("Start");
        stopButton = makeButton("Stop");
        stopButton.setEnabled(false);
        //Display the window.
        pack();
        setVisible(true);
    private class LocReport{
         private Location loc;
         private double val, rand;
         private boolean KS;
         LocReport(Location L, double value, boolean KillSpot, double random){
              this.loc = L;
              this.val = value;
              this.KS = KillSpot;
              this.rand = random;
private class RobotTask extends SwingWorker<Void, LocReport> {
    @Override
    protected Void doInBackground() {
        Grid grid = new Grid( GRID_SIZE );
         Location startPosition = grid.getLoc( 8, 8 );
         Robot jerry = new Robot( startPosition );
         Random rand = new Random();
         grid.fillGrid();
        //EastWestSentry ews = new EastWestSentry( grid.getLoc(5, 5));
         grid.getLoc( 3 , 3 ).setValue( 1.0 );
         grid.getLoc( 7 , 7 ).setValue( 0.0 );
         for( int i = 0; i < GRID_SIZE; i++){
              grid.getLoc( i, 4 ).isKillSpot = true;
         grid.getLoc(4, 5).isWindy    = true;
         grid.getLoc(7, 5).isKillSpot = true;
         grid.getLoc( 6, 4 ).isKillSpot = false;
         for( int i=0; i < NUMBER_OF_TIMES; i++ ){
         while ( jerry.getLocation() != grid.getLoc( 3 , 3 ) ){
         Location L = jerry.getLocation();
         double value = L.value;
         double random = rand.nextDouble();
         boolean isKS = L.KillSpot();
         publish( new LocReport(L,value,isKS,random) );
          if(jerry.getLocation().isWindy == true)
               jerry.move( grid.getLoc(7, 5) );
          if( jerry.getLocation().hasSentry )
                    jerry.getLocation().isKillSpot = true;     
          if(jerry.getLocation().isKillSpot == true){
               if( rand.nextDouble() > 0.5 ){
                    System.out.printf("Lucky this time. This killspot didn't kill me.\n");
               }else{
               grid.getLoc(jerry.getXCoord(), jerry.getYCoord()).setValue(-1);
               jerry.regenerate( startPosition );
          if(rand.nextDouble()>0.8){
               System.out.printf("I'm going exploring!\n");
               jerry.exploratoryMove();
          else{
               //ews.patrol();
               jerry.move();
               if( jerry.getMyPreviousLocation().isKillSpot &&
                    jerry.getMyPreviousLocation().getValue() > 0.0 ){
                    jerry.getMyPreviousLocation().setValue(-1);
         return null;
    protected void process(List<LocReport> locs) {
         LocReport location = locs.get( locs.size() - 1);
         movementText.append("========================\n");
         movementText.append("Robot is at location : " + location.loc.getXCoord() +
                               ", " + location.loc.getYCoord() + "\n");
         movementText.append("It's value is : " + location.val + "\n");
public void actionPerformed(ActionEvent e) {
    if ("Start" == e.getActionCommand()) {
        startButton.setEnabled(false);
        stopButton.setEnabled(true);
        (robTask = new RobotTask()).execute();
    } else if ("Stop" == e.getActionCommand()) {
        startButton.setEnabled(true);
        stopButton.setEnabled(false);
        robTask.cancel(true);
        robTask = null;
    * @param args the command line arguments
    public static void main(String args[]) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new RLGUIFrame();
}Edited by: zimmerPlease on Mar 23, 2010 3:58 PM

You're adding both components with the same GridBagConstraints without setting any of its attributes. Follow the link to the Swing tutorial efrom the topic listing page for this forum and click through to the Layouts section where you can learn how to use GridBagLayout and GridBagConstraints properly.
As an aside, there is no need to extend JFrame to create a GUI that has to show a JFrame. Favor composition over inheritance. And in this case, it leads to add(...) coode being all over the place where it can't be easily found.
db

Similar Messages

  • Images on Facebook do not appear when using different web browsers

    Images on Facebook do not appear when using Safari on my Macbook Pro (I've tried Google Chrome too with the same result).  This makes me think it's a setting within OS Mavericks that I'm missing.  I have not seen this issue on any other computers.  This only occurs on my, and others' profile pictures on my profile page and on the news feed, not photos that are posted in albums or on walls.  and yes, i have images enabled in Safari.
    In safari the images don't appear, and in their place is a small blue "?" square >>.
    In Chrome it appears as a broken image link >>
    Has anyone encountered this?  Is there a fix?  It is very annoying.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, or by corruption of certain system caches. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and  Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • Images not appear when using SUN IDE. help !

    I have the Sun IDE, and I have a problem. The problem is : when I compile using this IDE, Images do not appear.
    But when I compile using another IDE such as JPadPro, images appear well.
    Thank you !!

    [url http://forum.java.sun.com/thread.jsp?forum=10&thread=486965&tstart=0&trange=15]Please post enough code that someone can figure out what it is you are trying to do and what you have done.
    &#91;code&#93;public class SomeThing { // YOUR CODE HERE
        private Some some = new Some();
        public Thing thing = new Thing();
        public SomeThing() {
            doSomething();  // do something!!!
        public void doSomethng() {
            some.thing();
            thing.doThatFunky();
    &#91;/code&#93;
    Use code blocks to make your code more readable. (See [url http://forum.java.sun.com/features.jsp#Formatting]&#91;Formatting Help&#93; on the page you post on.)

  • Camera icon does not appear when use Google Image Search

    Hello,
    I am working on a much older macbook pro (2006) running OS 10.6.8 and Safari 5.1.10.
    Just the other day I reinstalled Safari, as some things appeared to not be working properly. However, there was nothing wrong with Google. SInce then, when I try to search by Google Image, the camera icon does not appear in the search bar. I have tried reinstalling Safari twice, but nothing changes. I have checked in Firefox and it shows up as expected.
    I have cleared the cache, deleted cookies, and cleared browser history. None of these steps have produced any changes.
    Also, I seem to have reverted to some earlier version of Google, since the search tools now appear on the top left, as show below.
    Can you please assist me in sorting this out so that Safari and Google perform as expected.
    Thank you very much.
    Val

    I posted that work around on the google forums and it actually came from the Apple forums from users 'Society Girl' and refined by 'spiza' from this thread.
    Google Reverted to Old Layout
    I called a friend at a tech magazine and he *cough* unofficially* cough* said via contacts it was a very deliberate move by Google... nothing to do with their upgrades or a hack coincidentally not working as a by product with old browsers.
    oh boy...
    'Google flushes out users of old browsers by serving up CLUNKY, AGED version of search'
    'Ad giant: Yeah, we did that deliberately'
    In a separate thread, as spotted by a Reg reader who brought this sorry affair to our attention, user MadFranko008 was able to show that even modern browsers - including the current version of Chrome - were apparently spitting out glitches on Apple Mac computers.
    Google then appeared to have resolved the search "bug" spotted in Chrome.
    http://www.theregister.co.uk/2014/08/31/google_search_browser_support/
    and on the BBC website...
    Google 'discourages' users of old browsers
    Google has started showing old versions of its search page to people using out-of-date versions of some web browsers.
    The problem was most pronounced among those using variants of Safari 5.1 and Opera 12.
    A Google message posted to the forum said the change was made to "encourage" people to upgrade their browser
    http://www.bbc.co.uk/news/technology-29012038
    Google and Apple are not the best of friends...
    I expect this will run a little longer 

  • AIM Application Icon does not appear when using Today Theme

    When using the 'BB Dimension Today' theme that came with my Blackberry Curve, the AIM application icon does not appear.  If I change back to any of the other themes, the icon reappears.  Any ideas as to why this is the case, or how I can use both the 'Today' theme as well as AIM?
    Thanks! 

    Welcome to the Frums
    Are they hidden behind another icon ? or just hidden (click menu and show all).  Sometimes that happens.
    Nurse-Berry
    Follow NurseBerry08 on Twitter

  • Error in transaction COGI does not appear when using FM BAPI_PROCORDCONF_CR

    Hi,
    I use FM BAPI_PROCORDCONF_CREATE_HDR to confirm the order but the error for goods movement does not appear in COGI but it does appear during manual confirmation in transaction COR6... can anyone help me with this? Thanks a lot!
    Rgds,
    Mark

    Hi,
    maybe QE11 is an option for recording results vai BIM.
    Cheers,
    S>

  • My entire TV show library does not appear when using home sharing to ipad

    I've tried everything to get my entire library to show when using home sharing on the ipad but it only displays the shows under letter A to the beginning of F.  Is there a limit on the seasons that can be displayed? Im streaming from itunes on a PC.

    I figured out my own problem. Thanks dmule you're a genius. All I had to do was turn off home sharing on my iPad and then turn it back on. Now all the video art work matches their proper movies.

  • Image not appearing when using product matrix

    We are using WebTools 2007 PL4.
    When a product with a matrix selection is ordered, the image of the product won't appear in the orderform of the SHOPPING CART.
    You can re-create by going to the www.riggers.com.au site.  A sample product is this
    http://www.riggers.com.au/B1WebTools/catalog/partdetail.aspx?partno=SL190
    If you order a product not using a matrix the image appears.
    http://www.riggers.com.au/B1WebTools/catalog/partdetail.aspx?partno=H4199
    Cheers
    Thomas

    Hi Thomas
    Make sure the items in the matrix have images assigned to them as well

  • AppStore Apps not appear when using SCCM 2012 R2

    I noticed that when I select AppStore app, nothing appear,
    But when Android is selected, Google Play appears as usual.
    I have turned off Windows firewall (for testing only) + I am NOT using any proxy .
    N.A.Malik

    Strange problem. I assume that you are running ConfigMgr console on a server.
    A couple of things to test:
    - Remove IE's Enhanced Security Configuration
    - Start ConfigMgr console with Run As Administrator option
    IE might block something from Apple's site, but not from Google's. Not sure though.
    Panu

  • Output not sorted when using group by clause

    Recently we migrated our application from Forms5 to Forms10g and database from 7.3.2 to 10gR2.
    More than 400 applications using sql stmt with "group by" clause and without "order by".
    In Earlier version of oracle 7.3.2 "group by" clause in SQL stmt sorts the output by order of the column in the "group by"
    stmt, where new version of oracle 10g (10.2.0.1.0 - 64bit Production) doesnt behave like older version.
    eg select div_cd,dept_cd,count(*) from class group by div_cd,dept_cd
    Output of the above query in Oracle7
    DIV_CD DEPT_CD COUNT(*)
    0 1     120
    0 9 131
    1 4 938
    1 6 1
    4 1 1490
    5 2 59
    6 6 848
    6 9 295
    8 1 45
    9 5 19
    Output of same query in Oracle10g
    DIV_CD DEPT_CD COUNT(*)
    0 6 120
    0 9 131
    4 1 1490
    6 9 295
    8 1 45
    9 5 19
    1 4 938
    1 6 1
    5 2 59
    6 6 848
    My question is
    a) Does the oracle behave in that manner?.
    b) if so, Any patch set available for this?
    c) if no patch set how to resolve this issue.
    if i use "order by" clause
    along with group by then i can get the output how i want.
    BUt problem is more than 400 applications (forms) using above method.
    Identify Forms/Reports and rectifing is a tedious job.
    Anyone can give me a good solution to solve the above issue

    Group By does not, and never has guaranteed order. Just because it happened that way on the past does not mean it will continue to do so.
    In the past, the algorithm used for Group By invoked a sort. It was convenient for the system to simply dump the output in that resulting order. These days, Group By could also be accomplished using a hash algorithm. Walking through the hash can easily result in a completely different ordering, as you have seen.
    Your problem is that the assumptions made previously are now invalid. Oracle is still working correctly. No patch, but you might be able to work around it by crippling your database and using the COMPATIBLE parameter (although the official lower limit is 9.2.0)

  • The menu button on my tablet does not appear when using firefox Aurora

    I have a tablet Android v4.0.3 and I installed Firefox 15c - Aurora via the downloaded apk file
    1. There is no entry in my list of application
    2. Firefox does not invoke the menu "soft button" on my tablet. I see the backup, HomePage and ActiveApplications, but not the menu button
    I am using an 8" tablet, ARM v7 variation, ARM cortex A10 the Momo
    I downloaded the full-screen add-on, but I do not have a nenu button
    I see all ther required toolbar icons in Aurora, so I do not have an issue there.

    The version of Aurora is 15.0b2 and not 15c as stated above. I downloaded Aurora on 2012-07-10, the day that I opened this problem qustion

  • My files, photos, email files, software programs, and all information did NOT transfer over to Mavericks (from Mt. Lion).  How do I get all my stuff to appear when using Mavericks?

    Will someone please help me?
    My files, photos, email files, software programs, calendar info, and all information did NOT transfer over to Mavericks (from Mt Lion).  How do I get all my stuff to appear when using Mavericks?
    My email did transfer over.
    Thank you.

    First click on the Apple > Logout and Log back in or restart the unit see if that solves it.  If it doesn't do you have a backup of your system prior to upgrade?  Check Disk Utility and see how much space is being used to make sure the drive wasn't somehow erased.

  • Since my last firefox update, I have been unable to type an email - the text box does not appear when I press 'reply' , or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] s

    Hello. Since my last firefox update, I have been unable to type an email - the box within which one would usually type does not appear when I press 'reply' to a received email, or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] successfully for well over a year. The provider says it is a browser problem. I can still add an attachment to the email header, which successfully can be sent, but the recipient gets my standard email 'signature' with font messages and the attachment. Can anyone help? My email addresses are [email protected] [this is the one with the issue] and [email protected] in English
    == today

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • My Songs in my Ipod Touch 4 is not appearing when I tried to Play it but when i insert to my PC and use Itunes, songs,playlist appears in I tunes.What do I need to do?Can someone help me?Many thanks

    My Songs in my Ipod Touch 4 is not appearing when I tried to Play it but when i insert to my PC and use Itunes, songs,playlist appears in I tunes.What do I need to do?Can someone help me?Many thanks

    Try:
    - Another cable
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer          
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • My keyboard will not appear when i am using Notes App

    My on screen keyboard does not appear when I use Notes app. The + sign (to add a new note) does not function to create a new note
    Does anyone have any answers
    Thanks

    Try closing the Notes app completely and see if it works when you re-open it : from the home screen (i.e. not with Notes 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Notes app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then you could try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

Maybe you are looking for

  • Panel is not getting refreshed.i see a jam of old and new graph and lines

    hi friends i am attaching my code .when i adjust the slider position the size of the graph will increase(scaling).when i scroll to see the entire graph the screen is not getting refreshed properly. no leads ..can be 3,12 ...try any arbitary ...(store

  • Regarding SAP Sales & distribution.

    Dear SAP Guru's ... I have a general Query.....Career Related. As SAP AG is Launching New products Such as SCM Enhancements BW and other IS versions.... What will be the future situation and Market of SAP SD Consultant. We also heard that it will be

  • Not able to edit Service Contract from WEBUI beacause of error

    Hi, I am trying to edit Service Contract from WEB UI. But, when ever I say edit, it is giving error saying "Document is being distributed. Changes are not possible". Can you please let me know, why such error comes..and how to rectify that. Thanks, S

  • I am unable to get my officejet pro 8500a plus online,

    my officejet pro 8500a plus used to work fine, but recently it is connected to the internet, as is my laptops, but not online - blue light is out.  I even brought a new laptop and still cannot get printer online - so obviously a printer error!!  Plea

  • Connect interface with XML File in jdeveloper

    Hello; i want to design a webservice that take an employee ID , and return all employee's data (like his name ,departement, phone,email....) i want to make interface and connect it with XML file wich has all employees data how can i connect the inter