Avoid flickering in JTable

how to avoid flickering in JTable,can any one help me with some sample codings
thank u very much

ofcourse am using firetablexxx methods of model,but flickering is there,anyhow tan u for ur reply.
actually there r some 75 rows,but am displaying 20 rows at a time,also using highlighter for this,highlighter is a separate thread,once the highlighter reaches the 20th row am showing the next 20 set of rows,here is the problem of flickering
u suggest to use firetabelxxx methods,i tried with this but flickering is there
so plz give a better solution
thanks
yas

Similar Messages

  • How to avoid flickering

    Hi
    I am working on a project and in that I have a canvas on which my mouse will be moving and I have a axes moving along the pointer.
    I used repaint in the mouseMove method this is causing flickering
    in my application is there any way to avoid this flickering
    I would appreciate if any one can provide solution
    with regards

    import java.awt.*;
    import java.awt.event.*;
    public class Flicker extends Canvas
        Image image;
        Point loc = new Point(-1, -1);
        public void paint(Graphics g)
            int w = getWidth();
            int h = getHeight();
            if(image == null)
                initImage(w, h);
            g.drawImage(image, 0, 0, this);
            g.setColor(new Color(200,220,240));
            g.drawLine(0, loc.y, w, loc.y);
            g.drawLine(loc.x, 0, loc.x, h);
        private void initImage(int w, int h)
            image = createImage(w, h);
            Graphics g = image.getGraphics();
            g.setColor(Color.white);
            g.fillRect(0,0,w,h);
            g.setColor(Color.blue);
            g.drawRect(w/12, h/12, w*5/6, h*5/6);
            g.setColor(Color.green.darker());
            g.fillOval(w/3, h/3, w/3, h/3);
            g.dispose();
        public void update(Graphics g)
            paint(g);
        public void setPoint(Point p)
            loc = p;
            repaint();
        public static void main(String[] args)
            Flicker flicker = new Flicker();
            AxisMover mover = new AxisMover(flicker);
            flicker.addMouseMotionListener(mover);
            Frame f = new Frame();
            f.addWindowListener(closer);
            f.add(flicker);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
        private static WindowListener closer = new WindowAdapter()
            public void windowClosing(WindowEvent e)
                System.exit(0);
    class AxisMover extends MouseMotionAdapter
        Flicker flicker;
        public AxisMover(Flicker f)
            flicker = f;
        public void mouseMoved(MouseEvent e)
            flicker.setPoint(e.getPoint());
    }

  • How to avoid pauses in Garbage Collection

    While doing performance test on a full load we found pauses. We captured GC and here are few instances of Full GC. We are running JVM 1.5, JBoss 4.2.x on RedHat Linux. Could some one guide me in avoiding those 17 secs and 10 sec pauses. Thanks
    3643.602: [Full GC   [PSYoungGen: 23948K->0K(155328K)] [PSOldGen: 1819363K->728226K(1864192K)] 1843311K->728226K(2019520K) [PSPermGen: 58042K->58042K(60928K)] 17.8018000 secs]
    51867.636: [Full GC   [PSYoungGen: 1176K->0K(165824K)] [PSOldGen: 230161K->227209K(1864192K)] 231337K->227209K(2030016K) [PSPermGen: 58577K->58091K(58496K)] 4.1231000 secs]
    5862.403: [Full GC   [PSYoungGen: 41791K->0K(126400K)] [PSOldGen: 1843013K->421307K(1864192K)] 1884805K->421307K(1990592K) [PSPermGen: 58161K->58161K(58624K)] 10.8445660 secs]
    62677.562: [Full GC   [PSYoungGen: 1192K->0K(166528K)] [PSOldGen: 229211K->230214K(1864192K)] 230403K->230214K(2030720K) [PSPermGen: 58466K->58466K(58752K)] 2.8801950 secs]

    In general you need to use double buffering if you want to avoid flickering. That means that instead of painting directly to the window you paint to a bitmap and then paint that bitmap to the window.
    There are probably plenty of articles on the internet about the subject, here's one I found on a quick search:
    http://www.codeproject.com/Articles/33/Flicker-Free-Drawing-In-MFC
    One thing that may be worth noting is that in some cases most of the flicker comes from the default painting of the window background. In some cases simply avoiding that (see the OnEraseBkgnd change in that articles) removes most of the flicker.

  • Flickering when reverse

    I just had my client looking over my film to them and I saw than on both og the clips I had reversed just to make things fit the motion was incorrect. Just like that you're going one frame back, then two frames forward, then one back again. This does of course not happen on my LCD screen, but as these guys still have the old CRT screen the picture is painted on, and since the footage is interlaced does not make the case any better.
    The best solution for me is to remove the clip, but is there a filter I can apply to it to avoid flickering motion.
    I remember the same kind of thing when I tried to reverse a clip back in the days when I was still cutting on Pinnacle, and that was even before they had reversing of clips possible; i had to cut up the clip frame by frame and then manually reorder them..

    When you reverse a clip 100%, you are also changing the field order, which looks like you know what on CRTs. Set it to none and see what you get.

  • DoubleBuffering problem with applet

    Hi,
    We are developing an applet with multiple screens. CardLayout is being used to flip between different panels in the systems. The applet contains huge JTable and chart components and huge amount of data, which makes the refreshing of the applet very slow. We tried the DoubleBuffering concept to reduce the flickering in the JApplet class.
    Now the questions are:
    1) Do we need to do double buffering for all the panels that are used in the system ?
    2) Is there any other better way that Sun suggests to avoid flickering problems ?
    Any help will be much appreciated. Also with the email content and problem definition thread is going on, any feedback about this email is also welcomed.
    Thanks
    Anoop

    One solution is to put all the packages in a jar file.

  • Problems with invokeing method

    Hey,
    I'm trying to create an splash screen before my app starts but i have alot of troubles with this. Here is my code:
    package classes;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import clientmanager.Delta;
    * A Splash window.
    *  <p>
    * Usage: MyApplication is your application class. Create a Splasher class which
    * opens the splash window, invokes the main method of your Application class,
    * and disposes the splash window afterwards.
    * Please note that we want to keep the Splasher class and the SplashWindow class
    * as small as possible. The less code and the less classes must be loaded into
    * the JVM to open the splash screen, the faster it will appear.
    * <pre>
    * class Splasher {
    *    public static void main(String[] args) {
    *         SplashWindow.splash(Startup.class.getResource("splash.gif"));
    *         MyApplication.main(args);
    *         SplashWindow.disposeSplash();
    * </pre>
    * @author Werner Randelshofer
    * @version 2.2.1 2006-05-27 Abort when splash image can not be loaded.
    public class SplashWindow extends Window {
         * The current instance of the splash window.
         * (Singleton design pattern).
        private static SplashWindow instance;
         * The splash image which is displayed on the splash window.
        private Image image;
         * This attribute indicates whether the method
         * paint(Graphics) has been called at least once since the
         * construction of this window.<br>
         * This attribute is used to notify method splash(Image)
         * that the window has been drawn at least once
         * by the AWT event dispatcher thread.<br>
         * This attribute acts like a latch. Once set to true,
         * it will never be changed back to false again.
         * @see #paint
         * @see #splash
        private boolean paintCalled = false;
         * Creates a new instance.
         * @param parent the parent of the window.
         * @param image the splash image.
        private SplashWindow(Frame parent, Image image) {
            super(parent);
            this.image = image;
            // Load the image
            MediaTracker mt = new MediaTracker(this);
            mt.addImage(image,0);
            try {
                mt.waitForID(0);
            } catch(InterruptedException ie){}
            // Abort on failure
            if (mt.isErrorID(0)) {
                setSize(0,0);
                System.err.println("Warning: SplashWindow couldn't load splash image.");
                synchronized(this) {
                    paintCalled = true;
                    notifyAll();
                return;
            // Center the window on the screen
            int imgWidth = image.getWidth(this);
            int imgHeight = image.getHeight(this);
            setSize(imgWidth, imgHeight);
            Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
            setLocation(
            (screenDim.width - imgWidth) / 2,
            (screenDim.height - imgHeight) / 2
            // Users shall be able to close the splash window by
            // clicking on its display area. This mouse listener
            // listens for mouse clicks and disposes the splash window.
            MouseAdapter disposeOnClick = new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    // Note: To avoid that method splash hangs, we
                    // must set paintCalled to true and call notifyAll.
                    // This is necessary because the mouse click may
                    // occur before the contents of the window
                    // has been painted.
                    synchronized(SplashWindow.this) {
                        SplashWindow.this.paintCalled = true;
                        SplashWindow.this.notifyAll();
                    dispose();
            addMouseListener(disposeOnClick);
         * Updates the display area of the window.
        public void update(Graphics g) {
            // Note: Since the paint method is going to draw an
            // image that covers the complete area of the component we
            // do not fill the component with its background color
            // here. This avoids flickering.
            paint(g);
         * Paints the image on the window.
        public void paint(Graphics g) {
            g.drawImage(image, 0, 0, this);
            // Notify method splash that the window
            // has been painted.
            // Note: To improve performance we do not enter
            // the synchronized block unless we have to.
            if (! paintCalled) {
                paintCalled = true;
                synchronized (this) { notifyAll(); }
         * Open's a splash window using the specified image.
         * @param image The splash image.
        public static void splash(Image image) {
            if (instance == null && image != null) {
                Frame f = new Frame();
                // Create the splash image
                instance = new SplashWindow(f, image);
                instance.setVisible(true);
                // Note: To make sure the user gets a chance to see the
                // splash window we wait until its paint method has been
                // called at least once by the AWT event dispatcher thread.
                // If more than one processor is available, we don't wait,
                // and maximize CPU throughput instead.
                if (! EventQueue.isDispatchThread()
                && Runtime.getRuntime().availableProcessors() == 1) {
                    synchronized (instance) {
                        while (! instance.paintCalled) {
                            try { instance.wait(); } catch (InterruptedException e) {}
         * Open's a splash window using the specified image.
         * @param imageURL The url of the splash image.
        public static void splash(URL imageURL) {
            if (imageURL != null) {
                splash(Toolkit.getDefaultToolkit().createImage(imageURL));
         * Closes the splash window.
        public static void disposeSplash() {
            if (instance != null) {
                instance.getOwner().dispose();
                instance = null;
         * Invokes the main method of the provided class name.
         * @param args the command line arguments
        public static void invokeMain(String className, String[] args) {
            try {
                //Class.forName(className).getMethod("main", new Class[] {String[].class}).invoke(null, new Object[] {args});
            } catch (Exception e) {
                InternalError error = new InternalError("Failed to invoke main method");
                error.initCause(e);
                throw error;
    }But when i run my application i get this:
    Exception in thread "main" java.lang.InternalError: Failed to invoke main method
            at classes.SplashWindow.invokeMain(SplashWindow.java:199)
            at clientmanager.Main.main(Main.java:14)
    Caused by: java.lang.ClassNotFoundException: Delta
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:169)
            at classes.SplashWindow.invokeMain(SplashWindow.java:197)
            ... 1 moreAnd i don't know why i get that error. Can anybody help me?
    Thanks alot!
    Sincerely,
    NightFox

    this i have created in java 2d
    the code: -
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class Draw2 extends Frame
         Shape s[] = new Shape[5];
         public static void main(String args[])
              Draw2 app = new Draw2();
         public Draw2()
              super("Draw2");
              add("Center", new MyCanvas());
              setSize(600, 400);
              show();
         class MyCanvas extends Canvas
              public void paint(Graphics graphics)
                   Graphics2D g = (Graphics2D) graphics;
                   for (int i=0; i<=5; i++)
                        g.draw(new Ellipse2D.Double(20+(60*i), 50.0, 50, 50));
                   for (int i=0; i<=5; i++)
                        g.draw(new Ellipse2D.Double(20+(50*i), 100.0, 50, 50));
                   for (int i=0; i<=5; i++)
                        g.draw(new Ellipse2D.Double(20+(40*i), 150.0, 50, 50));
                   for (int i=0; i<=5; i++)
                        g.draw(new Ellipse2D.Double(20+(30*i), 200.0, 50, 50));
                   for (int i=0; i<=5; i++)
                        g.draw(new Ellipse2D.Double(20+(20*i), 250.0, 50, 50));
    }hope this helps
    thanks
    Pradyut
    http://pradyut.tk

  • Information Regarding :Exception occurred during event dispatching

    Hi,
    I frequently get this exception when I click a button in a dialog and it opens up another frame of window. The exception trace includes java internal classes and my program classes line numbers. I have searched the net but could not get any concrete answer.
    Is this problem in java packages or should we take care of something in our code to avoid such exceptions.
    Below is the exception trace..........................
    Exception occurred during event dispatching:
    java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1141)
    at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
    at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
    at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
    at javax.swing.JComponent.paintComponent(JComponent.java:541)
    at javax.swing.JComponent.paint(JComponent.java:808)
    at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4795)
    at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4748)
    at javax.swing.JComponent._paintImmediately(JComponent.java:4692)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4495)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:409)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
    at java.awt.Dialog$1.run(Dialog.java:540)
    at java.awt.Dialog.show(Dialog.java:561)
    at java.awt.Component.show(Component.java:1192)
    at java.awt.Component.setVisible(Component.java:1147)
    at com.mycomp.example.DialogView.showWindow(DialogView.java:91)
    at com.mycomp.example.showWindow(StatusController.java:83)
    at com.mycomp.example.handleOk(ExampleController.java:842)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
    at java.awt.Component.processMouseEvent(Component.java:5159)
    at java.awt.Component.processEvent(Component.java:4956)
    at java.awt.Container.processEvent(Container.java:1569)
    at java.awt.Component.dispatchEventImpl(Component.java:3674)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    Thanks in advance.

    Hi All,
    Thanks for the replies and information posted by you.
    Below is some code snippet: ( complete code posting is difficult) ;-)
    Dialog1 is open, clicking on button say start it hides the current Dialog1 and opens the status dialog for Dialog1.
    Also, we are making the current Thread to sleep to avoid flickering.
    dialog1.hideWindow(); // Hide current window...
    Thread.currentThread().sleep(5); // sleep to avoid flickering..
    statusDialog.showWindow(); // to display status window..
    I will check and try to do modifications as per your suggestions.
    Thanks.

  • Problems with Fadeffect in IE

    Hi there,
    me again with slight problems ;-)
    I got a gallery on my site. Evertime you watch a picture it
    should fade in so i need auto fade in.
    i´ve created the following Js function
    function bildfader(){
    Spry.Effect.AppearFade('fadeobject',
    {duration:1000,from:0,to:100,toggle:false});
    HTML Code
    <div id="fadeobject">
    <script
    type="text/javascript">bildfader()</script>
    <img src="myimagepath">
    </div>
    Working fine in Firefox...not IE
    Can somebody help me out?
    bye Kahmoon

    This works...thank you. But you have to call the function
    after the imagetag. To avoid flickering of the image you have to
    add code to the imagetag
    HTML Code
    <div>
    <img src="myimagepath" id="fadeobject"
    style="filter:Alpha(opacity=0)">
    <script
    type="text/javascript">bildfader()</script>
    </div>

  • Double buffering for shape animation

    Hello people,
    I'm building an applet which animates some text (a shape with various setting for stroke, fill, etc.) and translating it from x1 to x2 using AffineTransform. How can I clear the screen to create an animation effect and double buffering to avoid flickering? Double buffering can be used with ImageS, but what about ShapeS?
    Many thanks

    Double buffering is a general concept that applies to all
    graphic objects.

  • Problem doing Applet exercise

    In my (swedish) course literature I am currently supposed to write an Applet that follows the actions of the window when it is resized . The point is to learn ComponentListener and making it runnable to avoid flickering.
    the applet is supposed to look like a red rectangle with a white cross.
    This is the script so far:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Main extends Applet implements ComponentListener{
        int left = 10, top = 10, rutbredd, ruth?jd;
        public void init(){
            Dimension appletsize = getSize();
            rutbredd = appletsize.width-20;
            ruth?jd = appletsize.height-20;
            addComponentListener( this);
        public void paint( Graphics g){
            Color col = new Color (255,0,0);
            g.setColor(col);
            g.fillRect(left,top,rutbredd,ruth?jd);
            g.setColor( Color.white);
            g.drawLine(left, top, left+rutbredd,top+rutbredd);
            g.drawLine(left+rutbredd,top,left, top+ruth?jd);
        public void componentResized( ComponentEvent e){
            Dimension appletsize =  getSize();
            if(rutbredd>appletsize.width-20){
                rutbredd=appletsize.width-20;
            if(rutbredd<appletsize.width-20){
                rutbredd=appletsize.width-20;
    }My mission is to make it runnable by adding 'Runnable' after 'implements ComponentListener' on the class-line and add these methods to the code:
        public void start(){
            Thread tr?d = new Thread( this);
            tr?d.start();
        public void run (){
            int fartbredd = -1, farth?jd = -1; // growth speed
            while(true){
                rutbredd += fartbredd;
                ruth?jd += farth?jd;
                Dimension appletSize= getSize();
                if(rutbredd <1){
                    fartbredd=1;
                if(rutbredd >appletSize.width){
                    fartbredd= -1;
                if(ruth?jd<1){
                    farth?jd=1;
                if(ruth?jd>appletSize.height){
                    farth?jd= -1;
                repaint();
                try { Thread.sleep(10);
                }catch( InterruptedException ie) {}
            }It does not say where to put these methods so I figured that perhaps I could put them just after the ones in script #1. Netbeans however gives an error message and Applet Viewer does not show any output at all.. (I get the usual 'Start: applet not intialized'). Does this work for anyone else?
    By the way, after copy-pasting it to another editor and back netbeans gives an error message on the first (originally working) script. This worked before I copied it to and back from another programming editor (bluefish). perhaps it is just netbeans not woking when moving stuff around too much?
    I have been trying to solve this for two hours. please help me put this script together!
    Thanks in advance.

    uj2n wrote:
    gives an error messageI'm sorry but I skipped the mind reading class at school. Perhaps you can share the error message(s) with us.

  • Transparency problem, please help

    hi there. i've read a lot on several forums about using partialy transparent images in java, but didn't figured out how to do it. This is what i'm doing so far:
    1. paint an image in Gimp, convert it from rgb to indexed and export it as a gif with transparency(i know that because when i'm opening it in an image viewer the area that suppose to be transparent is transparent).
    2.I'm loading it using Toolkit and MediaTracker objects into Java, then i put it into a BufferedImage object using TYPE_BYTE_INDEX as it's type(i found out it works pretty well with rgb too).
    now in my little game i'm first composing the whole frame into a BufferedImage, then draw that image onto the screen, to avoid flickering(it doesn't helps if i enable double buffering). The problem is that the transparent area of the .gif image appears black, which is a very undesired result i'm fighting with since 3 days ago. Can you please help me? (a simple code example will do just fine, because i've read a lot of theory and can't do anything with it). Thanks for reading.

    Post a minimal example program demonstrating your problem.

  • Resolution on 20" ACD in XP SP2

    I'm having trouble setting up a 20" ACD on my pc which has an ASUS AX800PRO/TVD/256M graphics card.
    The graphics card is capable of a resolution of 1600x1200. According to the manual the manual ACD works best at 1680X1050.
    I seem to have the following options, none of which appeal to me;
    - 1280X1024
    This leaves two large areas of unusable screen space
    - 1280X1024 Scaled to size of the display
    Everything is stretched and out of shape
    - 1600X1200
    The desktop goes beyond the visible area
    There doesn't appear to be an option to scale 1600X1200 back down to the size of the display.
    I thought the WinACD utility may help so I downloaded and installed it. It didn't solve my problem and also didn't seem to work as expected. Maybe the two issues are related.
    Should I persevere with getting the WinACD utility working am I limited to the above options with this graphics card?
    Or, if someone could suggest something else I'd be greatly appreciative.
    It didn't appear obvious to me what the program actually does. I searched this forum and the download site where the WinACD utility is located.
    Thanks

    Finally got it working!!!!
    Thanks for the pointing me in the right direction. I downloaded the Catalyst drivers as you suggested but it still didn't work. After some further searching I found the following information and now it's working fine and looking good.
    ATI x800 Pro (1 good one bad) (but to avoid flickering, be sure to uncheck both
    Reduce DVI frequency on hi-res displays
    AND
    Alternate DVI operational mode.
    ALSO:
    download newest Catalyst drivers change advanced display settings
    enable V-Sync
    make sure applicationsin full-screen mode keep the same 60hz refresh rate

  • How to make a game smooth

    Hi there,
    i am developing a game and have all but finished it. But there is a problem, when i want to play the
    game in a larger applet size it goes slower and flashes. i have set the priority level of the thread to 1.but it
    still does it. What am i missing?

    Priority 1?
    Thread.MAX_PRIORITY seems better.
    You'd still need double buffering to avoid flickers, though.
    + add two member variables:
    + insert two lines into yout init()-method
    + write an update()-method
    Image bgi;
    Graphics bgi_g;
    public void init(){
    bgi= createImage( 400,400);
    bgi_g= bgi.getGraphics();
    public void update( Graphics g){
    paint( bgi_g);
    g.drawImage( bgi, 0,0, this);
    }

  • Anybody who wants to moderate an IO working program - come on do it

    It just works -- help to improvr
    run it first then try to understand
    The project is to be submitted before april 15th - I discovered java around August last year
    My programing background only Pascal - 4 years ago
    For a novice - I'm really good....in getting results... not in clean programming...sorry
    // legend
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ will mean a new file, another file or the end of the file
    //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ will mean read this instruction
    // ok lets go
    //^^^^^^^^^ The following code is written in notepad and saved as test.bat
    // this file can be saved in jdk/bin as test.bat
    //~~~~~~~~~ begin file > test.bat
    keytool -delete -alias mykey -keystore "C:\Program Files\JavaSoft\JRE\1.3.1\lib\security/cacerts" -storepass changeit
    javac newoscillo13.java
    jar cvf myoscillo.jar newoscillo13.class
    del c:\windows\.keystore
    keytool -genkey -alias mykey -keypass tarachand -dname "cn=test" -storepass tarachand
    jarsigner -signedjar hellosigned.jar -storepass tarachand myoscillo.jar mykey
    keytool -export -alias mykey -file mykey.cer -storepass tarachand
    keytool -import -file mykey.cer -keystore "C:\Program Files\JavaSoft\JRE\1.3.1\lib\security/cacerts" -storepass changeit
    del newoscillo13.class
    //~~~~~~~~~ end file > test.bat
    //^^^^^^^^^ save the following file as datafile.txt in jdk/bin
    //~~~~~~~~~ begin file > datafile.txt this file consists of data ranging from 0 to 300
    140 162 340 45 300 300 60 200 20 300
    100 16 2 45 300 3 50 64 250 220     
    100 360 20 390 40 50 25 10 0 294
    230 200 309 140 162 310 45 300 300 60 200 20
    //~~~~~~~~~ end file > more data must be added I've given u just this few
    //^^^^^ Heres the main program. save it as newoscillo13.java in jdk/bin
    //~~~~~~~~~~ begin newoscillo13.java
    import java.awt.*;
    import java.awt.Graphics;
    import java.applet.Applet;
    import java.util.*;
    import java.lang.*;
    import java.text.*;
    import java.io.*;
    public class newoscillo13 extends Applet implements Runnable {
         Thread timer;// thread to produce a delay before repainting
         int delay = 1000;// delay between readings in ms
         boolean initialiser = true;
         String[] nowdate = new String[13];
    // defining the oscilloscope coordinates variables
         int screentop = 36;// where the oscillo grid starts
         int screenright = 55; // where the oscillo grid starts
         int screenheight = 400; // size of oscillo
         int screenwidth = 480;// size of oscillo
         int numofcolumns = 12;
         int numofrows = 10;
         int rowheight = screenheight/numofrows;
         int grid = screenwidth/(numofcolumns*5); // grid size
         int numofpoints = 61;
         int[] measuredval = new int[numofpoints +1]; // this array will contain the points to display on the oscillo
         int originx = screenright; // pixel coordinates 5
         int originy = (screentop+screenheight/2);// pixel coordinates 2 + 320/2 = 162
         int xmax = screenright + screenwidth;
         int ymax = screentop + screenheight;
         Color lineColor = Color.white;
         Color gridColor = Color.red;
         Color oscilloBgnd = Color.blue;
         Color fontColor = Color.black;
         Color borderColor = Color.red;
         Color measuredvaldispbgnd = Color.green;
    // start programing
         public void init() { }
    // starting paint
         public void paint(Graphics g){
         setBackground(Color.white);
         g.setColor(borderColor);
         g.fillRect(screenright-3,screentop-3,screenwidth+6,screenheight+6);
         g.setColor(oscilloBgnd);
         g.fillRect(screenright,screentop,screenwidth,screenheight);
         g.setColor(gridColor);
         g.drawLine(screenright,screentop+screenheight/2,screenright+screenwidth,screentop+screenheight/2);
         g.drawLine(screenright+screenwidth/2,screentop,screenright+screenwidth/2,screentop+screenheight);
         for (int i=screenright; i< screenright+screenwidth+1; i= i+grid*5) {
         g.drawLine(i,screentop,i,screentop+screenheight);}//vertical lines on oscillograph
         for (int i=screenright; i< screenright+screenwidth+1; i= i+grid) {
         g.drawLine(i,screentop+screenheight/2-5,i,screentop+screenheight/2+5);}
         for (int i=screentop; i< screentop+screenheight+1; i= i+screenheight/10) {
         g.drawLine(screenright,i,screenright+screenwidth,i);}// horizon lines on oscillograph
         for (int i=screentop; i< screentop+screenheight+1; i= i+screenheight/50) {
         g.drawLine(screenright+(screenwidth/2)-5,i,screenright+(screenwidth/2)+5,i);}
    // reading a text file > datafile.text placed in c:\jdk1.3.1\bin
    int [] measuredval = new int[numofpoints +1];     
    int measuredvalue;
    try {
    RandomAccessFile f = new RandomAccessFile ("c:\\jdk1.3.1\\bin\\datafile.txt", "r");
    int dataarraysize = 0;
    String s;
              while ( (s=f.readLine()) != null )                          {
                   StringTokenizer st = new StringTokenizer(s);
                                  while (st.hasMoreTokens()) {
                        measuredvalue = Integer.parseInt(st.nextToken());
                        if (dataarraysize < numofpoints +1) measuredval[dataarraysize] = measuredvalue;
                        if (dataarraysize>numofpoints) {
                        measuredval[numofpoints] = measuredvalue;
                        for (int k =1; k <= (numofpoints -1); k++) measuredval[k] = measuredval[k+1];
                        dataarraysize++;
                             }     // end while
                             }     // end try
    catch (Exception e) {System.out.println("Execption in constructor readertext13: "+e); } // end catch
                   for (int a = 0;a<=(numofpoints -1);a++){
                   if (measuredval[a] < 0) measuredval[a] = 0;
                   if (measuredval[a] > screenheight) measuredval[a] = screenheight;
                   //System.out.println(""+measuredval[a]);
    // display date and temperature horizontally below the oscilloscope
         SimpleDateFormat now1 = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
         Date now = new Date();
         String nowstring = now1.format(now);
         g.setColor(measuredvaldispbgnd);
         g.fillRect(screenright - 4,ymax+5+40,screenwidth+8,20);
         int val = measuredval[numofpoints-1];
         g.setColor(fontColor);
         g.drawString(""+nowstring +" Temperature = "+val+"�C", screenright+10,ymax + 20+40);
    // x axis labelling - temporary
    SimpleDateFormat axisdate = new SimpleDateFormat("mm:ss");
    Date noww = new Date();
    while (initialiser) {
    for (int ii = 0; ii<13;ii++) nowdate[ii] = axisdate.format(noww);
    initialiser = false;}
    //---------------888888888888888
    // labelling x axis - time for each column
    for (int nw = 0;nw<12;nw++){
    nowdate[nw] = nowdate[nw + 1]; }
    nowdate[12] = axisdate.format(now);
    int wn = 0;
    while (wn <12) {
    g.drawString(nowdate[wn], screenright wn*40 - 17 ,screentopscreenheight+20);
    g.drawString(nowdate[wn+1], screenright +(wn+1)*40-17 ,screentop+screenheight+20);
    wn = wn +2;}
    g.drawString(nowdate[12], screenright + numofcolumns*40-17 ,screentop+screenheight+20);
    // label y axis
         //labeling vertical axis
         g.setColor(fontColor);
         for (int n = 0;n<11;n++) {
         int gridlabel = (screenheight - n*40);
         g.drawString(""+gridlabel+"�C", screenright - 45,screentop+screenheight*n/10 +4);
    // title label
         g.setColor(measuredvaldispbgnd);
         g.fillRect(screenright-3,5,screenwidth+5,20);
         g.setColor(fontColor);
         g.drawString("Graph of temperature measured against time at which it was measured", screenright+7, 18);
    // end label axes
         // draw another graphic , vertical display
         g.setColor(Color.gray);
         g.fillRect(xmax+10,screentop,16,screenheight+4 );
         g.setColor(gridColor);
         g.fillRect(xmax+12,screentop+2,12,screenheight);
         // above are fixed rectangles below is a pulsating rectangle depending on val
         g.setColor(oscilloBgnd);
         int zerotemp = screentop + screenheight + 2;
         int temperature = screenheight - val;
         g.fillRect(xmax+12,screentop+2,12,temperature);
    // end draw another graphic--------------------------------------------------------------
    // graphic display of temperature -- this is most important, the movie
         originx = screenright;
         originy = screentop + screenheight - measuredval[0];
    // draw 10 line segments     
         for (int i = 1; i <= (numofpoints -1);i++){
         g.setColor(lineColor);
         g.drawLine(originx,originy,originx+grid,screentop + screenheight - measuredval);
    // the starting point is originx, originy
    // the lowest point of the oscillograph is taken as 0, so screentop + screenheight
    // the end point of the line is originx+grid,screentop + screenheight - measuredval[i]
    // the above coordinates become the next starting point
         originx = originx+grid;
         originy = screentop + screenheight - measuredval[i];
    // ending paint
    public void destroy() {  }
    public void start() {
    timer = new Thread(this);
    timer.start();
    public void stop() {
    timer = null;
    public void run() {
    Thread me = Thread.currentThread();
    while (timer == me) {
    try {
    Thread.currentThread().sleep(delay);// wait for delay ms
    } catch (InterruptedException e) {
    System.out.println("Exception in method run: "+e);
    repaint();
    // start update to avoid flickering of the image
    private Image offScreenImage;
    private Dimension offScreenSize;
    private Graphics offScreenGraphics;
    public final synchronized void update (Graphics g) {
    Dimension d = getSize();
    if((offScreenImage == null) || (d.width != offScreenSize.width) || (d.height != offScreenSize.height))
    offScreenImage = createImage(d.width, d.height);
    offScreenSize = d;
    offScreenGraphics = offScreenImage.getGraphics();
    offScreenGraphics.clearRect(0, 0, d.width, d.height);
    paint(offScreenGraphics);
    g.drawImage(offScreenImage, 0, 0, null); }
    // end update ton avoid flickering
    }// end applet
    //~~~~~~~~~~ end newoscillo13.java
    //^^^^^^^^^ now the html part
    //~~~~~~~~~ save as newoscillo13.html
    <HTML><BODY>
    <OBJECT classid="clsid:CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA"
    codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0" WIDTH=600 HEIGHT=600>
    <PARAM NAME = CODE VALUE = newoscillo13 >
    <PARAM NAME = ARCHIVE VALUE ="hellosigned.jar" >
    <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.3.1">
    </OBJECT>
    </BODY></HTML>
    //~~~~~~~~~ save as newoscillo13.html in jdk/bin
    //^^^^^^^^^ go to dos > go to C:\jdk1.3.1\bin>
    //^^^^^^^^^ type test and then enter
    //^^^^^^^^^ wait to type yes and then enter
    // go back to windows, make sure java plug in advanced tab has c:\program files\javasoft\jre1.31
    now you can execute the html file newoscillo13.html and please it would be fantastic to
    send me your comments and suggestions to improve the program.
    I'm suzanne available at [email protected]

    Here are my suggestions:
    1) Get rid of the signing stuff -- you don't need it if you make the changes as I documented in the code posted below. Java applet can read any data file as long as the files are kept under the same document or code base -- notice that filename is specified without a path (i.e., it's relative). This makes it easier to deploy on the web
    2) Since you do not need to sign the applet, you don't need to create a jar file.
    3) Since you are not using anything special like swing, use the modified HTML shown below and you'll not have to worry about downloading Java plugin because the modified code will work with IE's native JVM version 1.1.4 and NN's native JVM version 1.1.5 -- should you make additions to the code, make sure that you're not calling methods implemented by Sun after the versions described.
    If this helps, give me the Dukes.... If you have more questions, ask!
    V.V.
    PS: The changes have been tested with the appletviewer, IE5, IE5.5, NN4.79 and NN6.2
    HTML
    ======
    <HTML><BODY>
    <APPLET CODE="newoscillo13.class" CODEBASE="." width=600 height=600></APPLET>
    </BODY></HTML>
    JAVA FILE
    ========
    import java.awt.*;
    import java.awt.Graphics;
    import java.applet.Applet;
    import java.util.*;
    import java.lang.*;
    import java.text.*;
    import java.io.*;
    import java.net.*;        //<---------- V.V.
    public class newoscillo13 extends Applet implements Runnable {
       Thread timer;
       // thread to produce a delay before repainting
       int delay = 1000;
       // delay between readings in ms
       boolean initialiser = true;
       String[] nowdate = new String[13];
       // defining the oscilloscope coordinates variables
       int screentop = 36;
       // where the oscillo grid starts
       int screenright = 55;
       // where the oscillo grid starts
       int screenheight = 400;
       // size of oscillo
       int screenwidth = 480;
       // size of oscillo
       int numofcolumns = 12;
       int numofrows = 10;
       int rowheight = screenheight/numofrows;
       int grid = screenwidth/(numofcolumns*5);
       // grid size
       int numofpoints = 61;
       int[] measuredval = new int[numofpoints +1];
       // this array will contain the points to display on the oscillo
       int originx = screenright;
       // pixel coordinates 5
       int originy = (screentop+screenheight/2);
       // pixel coordinates 2 + 320/2 = 162
       int xmax = screenright +
          screenwidth;
       int ymax = screentop +
          screenheight;
       Color lineColor = Color.white;
       Color gridColor = Color.red;
       Color oscilloBgnd = Color.blue;
       Color fontColor = Color.black;
       Color borderColor = Color.red;
       Color measuredvaldispbgnd = Color.green;
       // start programing
       private URL Codebase;     //<---------- V.V.
       public void init() {
          Codebase=getCodeBase();     //<---------- V.V.
       // starting paint
       public void paint(Graphics g) {
          setBackground(Color.white);
          g.setColor(borderColor);
          g.fillRect(screenright-3,screentop-3,screenwidth+6,screenheight+6);
          g.setColor(oscilloBgnd);
          g.fillRect(screenright,screentop,screenwidth,screenheight);
          g.setColor(gridColor);
          g.drawLine(screenright,screentop+screenheight/2,screenright+screenwidth,screentop+screenheight/2);
          g.drawLine(screenright+screenwidth/2,screentop,screenright+screenwidth/2,screentop+screenheight);
          for (int i=screenright; i< screenright+screenwidth+1; i= i+grid*5) {
             g.drawLine(i,screentop,i,screentop+screenheight);
          //vertical lines on oscillograph
          for (int i=screenright; i< screenright+screenwidth+1; i= i+grid) {
             g.drawLine(i,screentop+screenheight/2-5,i,screentop+screenheight/2+5);
          for (int i=screentop; i< screentop+screenheight+1; i= i+screenheight/10) {
             g.drawLine(screenright,i,screenright+screenwidth,i);
          // horizon lines on oscillograph
          for (int i=screentop; i< screentop+screenheight+1; i= i+screenheight/50) {
             g.drawLine(screenright+(screenwidth/2)-5,i,screenright+(screenwidth/2)+5,i);
          // reading a text file > datafile.text placed in c:\jdk1.3.1\bin
          int [] measuredval = new int[numofpoints +1];
          int measuredvalue;
          try {
    //       RandomAccessFile f = new RandomAccessFile ("c:\\jdk1.3.1\\bin\\datafile.txt", "r");
    * Comments by V.V.
    * disk files are random but streams from network are not.  Since the data is being read sequentially anyway,
    * the modifications shown below will allow you to read the data file without the need for the applet to be signed
             URL url=new URL(Codebase,"datafile.txt");                       //<---------- put file in same directory as the class file ---- V.V.
             InputStream in;                                                 //<---------- V.V.
             URLConnection connection=url.openConnection();                  //<---------- V.V.
             in=connection.getInputStream();                                 //<---------- V.V.
             BufferedReader f=new BufferedReader(new InputStreamReader(in)); //<---------- V.V.
             int dataarraysize = 0;
             String s;
             while ((s=f.readLine()) != null ) {
                StringTokenizer st = new StringTokenizer(s);
                while (st.hasMoreTokens()) {
                   measuredvalue = Integer.parseInt(st.nextToken());
                   if (dataarraysize < numofpoints +1) measuredval[dataarraysize] = measuredvalue;
                   if (dataarraysize>numofpoints) {
                      measuredval[numofpoints] = measuredvalue;
                      for (int k =1; k <= (numofpoints -1); k++) measuredval[k] = measuredval[k+1];
                   dataarraysize++;
             // end while
          // end try
          catch (Exception e) {
             System.out.println("Execption in constructor readertext13: "+e);
          // end catch
          for (int a = 0;a<=(numofpoints -1);a++){
             if (measuredval[a] < 0) measuredval[a] = 0;
             if (measuredval[a] > screenheight) measuredval[a] = screenheight;
             //System.out.println(""+measuredval[a]);
          // display date and temperature horizontally below the oscilloscope
          SimpleDateFormat now1 = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
          Date now = new Date();
          String nowstring = now1.format(now);
          g.setColor(measuredvaldispbgnd);
          g.fillRect(screenright - 4,ymax+5+40,screenwidth+8,20);
          int val = measuredval[numofpoints-1];
          g.setColor(fontColor);
          g.drawString(""+nowstring +
             " Temperature = "+val+
             "�C", screenright+10,ymax +
             20+40);
          // x axis labelling - temporary
          SimpleDateFormat axisdate = new SimpleDateFormat("mm:ss");
          Date noww = new Date();
          while (initialiser) {
             for (int ii = 0; ii<13;ii++) nowdate[ii] = axisdate.format(noww);
             initialiser = false;
          //---------------888888888888888
          // labelling x axis - time for each column
          for (int nw = 0;nw<12;nw++){
             nowdate[nw] = nowdate[nw +
                1];
          nowdate[12] = axisdate.format(now);
          int wn = 0;
          while (wn <12) {
             g.drawString(nowdate[wn], screenright wn*40 - 17 ,screentopscreenheight+20);
             g.drawString(nowdate[wn+1], screenright +(wn+1)*40-17 ,screentop+screenheight+20);
             wn = wn +2;
          g.drawString(nowdate[12], screenright +
             numofcolumns*40-17 ,screentop+screenheight+20);
          // label y axis
          //labeling vertical axis
          g.setColor(fontColor);
          for (int n = 0;n<11;n++) {
             int gridlabel = (screenheight - n*40);
             g.drawString(""+gridlabel+
                "�C", screenright - 45,screentop+screenheight*n/10 +4);
          // title label
          g.setColor(measuredvaldispbgnd);
          g.fillRect(screenright-3,5,screenwidth+5,20);
          g.setColor(fontColor);
          g.drawString("Graph of temperature measured against time at which it was measured", screenright+7, 18);
          // end label axes
          // draw another graphic , vertical display
          g.setColor(Color.gray);
          g.fillRect(xmax+10,screentop,16,screenheight+4 );
          g.setColor(gridColor);
          g.fillRect(xmax+12,screentop+2,12,screenheight);
          // above are fixed rectangles below is a pulsating rectangle depending on val
          g.setColor(oscilloBgnd);
          int zerotemp = screentop +
             screenheight +
             2;
          int temperature = screenheight - val;
          g.fillRect(xmax+12,screentop+2,12,temperature);
          // end draw another graphic--------------------------------------------------------------
          // graphic display of temperature -- this is most important, the movie
          originx = screenright;
          originy = screentop +
             screenheight - measuredval[0];
          // draw 10 line segments
          for (int i = 1; i <= (numofpoints -1);i++){
             g.setColor(lineColor);
             g.drawLine(originx,originy,originx+grid,screentop +
                screenheight - measuredval[ i ]);
             // the starting point is originx, originy
             // the lowest point of the oscillograph is taken as 0, so screentop + screenheight
             // the end point of the line is originx+grid,screentop + screenheight - measuredval
             // the above coordinates become the next starting point
             originx = originx+grid;
             originy = screentop +
                screenheight - measuredval[ i ];
          // ending paint
       public void destroy() {
       public void start() {
          timer = new Thread(this);
          timer.start();
       public void stop() {
          timer = null;
       public void run() {
          Thread me = Thread.currentThread();
          while (timer == me) {
             try {
                Thread.currentThread().sleep(delay);
                // wait for delay ms
             catch (InterruptedException e) {
                System.out.println("Exception in method run: "+e);
             repaint();
       // start update to avoid flickering of the image
       private Image offScreenImage;
       private Dimension offScreenSize;
       private Graphics offScreenGraphics;
       public final synchronized void update (Graphics g) {
          Dimension d = getSize();
          if ((offScreenImage == null) || (d.width != offScreenSize.width) || (d.height != offScreenSize.height)) {
             offScreenImage = createImage(d.width, d.height);
             offScreenSize = d;
             offScreenGraphics = offScreenImage.getGraphics();
          offScreenGraphics.clearRect(0, 0, d.width, d.height);
          paint(offScreenGraphics);
          g.drawImage(offScreenImage, 0, 0, null);
       // end update ton avoid flickering
    // end applett

  • R U A JAVA GURU

    Hello Java Guru,
    I am writing a simple applet to load an animated gif file. I am using double buffering to avoid flickering. So I want to load the animated gif file to the offscreen buffer during the initialisation of the applet. For that to happen I am using MediaTracker for wait for the loading of the file during initialisation. I am getting the file completly loaded but when I am drawing the file on screen I am getting only the first frame of the animated gif file. When I am trying to draw the animated gif without the buffer I am getting all the frames on the screen. Please anyone can help to resolve my problem. I don't know whether this is a bug of Java. It will be very helpful for me.
    Thanking you,
    Rahul

    Could you post up the code you're using to display this animated image?
    Sounds like you're not adding the ImageObserver to the Image or you're not regenerating the offscreen image at the right time.

Maybe you are looking for

  • Oracle 10g - query is very slow in jdbc but not in other tools

    I'm using PreparedStatement to execute a query with some parameters. in sql developer, it just spends 12 seconds but in jdbc, it's around 140 seconds. I disabled "_optim_peek_user_binds" parameter already but it didn't help. alter session set "_optim

  • WEBUTIL: ora-305501 when running howto_ole.html

    When running OTN demo file http://otn.oracle.com/products/forms/htdocs/webutil/howto_ole.html Word gets open and text replaced but SaveAs command is not executed. Instead. Error ora-305501 is displayed in the forms status bar. I have only changed the

  • HTTP Post WSDL in J2EE/HOME ?

    A customer created a BPEL process which has a partner-link defined for a WSDL located in the same directory as the project's bpel.xml file. The partner-link is to perform a http post using http binding. (basically the WSDL points to a deployed Servle

  • Handling Mail  exceptions or invalid email

    What I want to be able to do is to determine if to recipeints email actual exists when I try to send and email. I need this for regidtration process so that if I can not send confirmation email to cliant then I o not want to add them to my database u

  • I am having trouble syncing my iphone to mac

    i just bought a new mac, and i have attempted to sync my iphone wireless.  the "sync now" under itunes wi-fi sync does not , or will not work.  any ideas why? both the mac and the iphone are on a shared home wifi. is there a setting im missing in whi