Results 1 to 2 of 2
  1. #1
    yprabathme is offline Member
    Join Date
    Aug 2010
    Posts
    1
    Rep Power
    0

    Exclamation JFreeChart With Threads

    I have tried to assign the JFree chart meters with Threads. But not get the value. Pls help me. This is the code I have written.


    import javax.swing.JFrame;
    //Meters Class

    class MyshowMeters extends Thread {

    int xpos = 100;
    int ypos = 50;
    float meterval1;
    float meterval2;
    float meterval3;

    public void getArray(float f1,float f2,float f3){
    meterval1 = f1;
    meterval2 = f2;
    meterval3 = f3;
    }

    public void run() {
    Meters meter1 = new Meters("Meter 1");
    meter1.pack();
    meter1.setLocation(xpos, ypos);
    meter1.setAlwaysOnTop(true);
    meter1.setVisible(true);

    Meters meter2 = new Meters("Meter 2");
    meter2.pack();
    meter2.setLocation(xpos, ypos + 320);
    meter2.setAlwaysOnTop(true);
    meter2.setVisible(true);

    Meters meter3 = new Meters("Meter 3");
    meter3.pack();
    meter3.setLocation(xpos + 320, ypos );
    meter3.setAlwaysOnTop(true);
    meter3.setVisible(true);

    while (true){
    meter1.setdataset(meterval1);
    meter2.setdataset(meterval2);
    meter3.setdataset(meterval3);

    //meterval1,2,3 values are not assign from the getArray method

    }
    }
    }

    //here, I wants to pass the getArray values to run() but it not happen..

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Since you're calling Swing code, you should not do this on a background thread, but rather on the EDT or event dispatch thread. The Sun Swing tutorials can tell you more about this. I have a feeling though that this is not the cause of your current problems though, but rather the while(true) is likely squashing your Swing thread. Please read this:

    Concurrency in Swing

Similar Threads

  1. JFreeChart 1.0.11
    By Java Tip in forum Java Software
    Replies: 3
    Last Post: 04-18-2014, 09:27 PM
  2. Jfreechart help
    By shruti in forum AWT / Swing
    Replies: 1
    Last Post: 07-11-2009, 05:16 AM
  3. JfreeChart
    By puk284 in forum Advanced Java
    Replies: 1
    Last Post: 05-12-2009, 05:52 PM
  4. JFreeChart 1.0.7
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 11-17-2007, 03:13 PM
  5. JFreeChart 1.0.5
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-10-2007, 06:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •