Still not understanding Swing Double buffering

I'm writing a custom JComponent like
class Custom extends JComponent {
protected void paintComponent(Graphics g) {
       //slow complex routine
}As the display does not often change I thought I could improve performance with my own off-screen rendering
class Custom extends JComponent {
private Image screenImage= null;
private void doOffscreen() {
            BufferedImage backimage = defaultgc.createCompatibleImage(getSize().width, getSize().height);
            final Graphics2D g2 = backimage.createGraphics();
             slow complex routine
            screenimage = backimage;
protected void paintComponent(Graphics g) {
       super.paintComponent(g);
       if (screenimage != null) {
            g.drawImage(screenimage, 0, 0, null);
}What does adding
class Custom extends JComponent {
       public Custom() {
            setDoubleBuffering(true);
}get me ? Or can I use the SWING double buffer to render to ?
I'm guessing what it will do is render my screen image into yet another image and then switch this in.
I feel I'm missing something :(

I've run your code and it seems to work well,
however it is in constant update mode where as my application usually only changes as a part of user interactionActually, that doesn't matter, since when you want the screen to update, you just call "repaint()" from any place that has visibility in your application. The real wonderful thing about offscreen rendering is: that when you have to have an update done, it paints immediately is a very optimized code--a one line paint/paintComponent routine, since the image is pre-rendered, no waiting.
The offscreen rendering approach lends very well to animation loops, adhoc graphic updates, and pretty much any other animation schemes I've been able to come up with.
There is really only one concern that I have in offscreen renderings: it is possible that you would be able to catch the offscreen image being rendered so only a partial image would be present on the screen. I cannot make it do this so I can notice it happen in any animation loop or continuous update scenario that I've been able to test.
I can force it to happen noticeably in code if I purposefully artificially extend the animation times far beyond what they may normally take and unreasonably make multiple tick cycles to the animation and update delays. This is like running a film in ultra slow motion--frame by frame, but under normal conditions (full speed animations), I cannot force any noticeable flaw in the output of an offscreen rendering scheme.
I've pumped that program that I posted up to 10,000 objects and it still ran--no flicker what so ever, but yes, it was a little jerky since I'm doing 1600x1200 and 10,000 images on a 2.4 GHz AMD under Solaris x64, but at the 1,000 object mark as posted, it works fine.

Similar Messages

  • DAQEvent=2 not fired when double buffered operations stop

    Hi,
    I am using Config_DAQ_Event_Message with DAQEvent==2 to get an event when synchronous DAQ and WFM are finished. This works fine with single buffered operation, but i get no event in double buffered mode ?
    Especially I like to get an event in case of Buffer-Underrun etc. errors.
    My hardware: PCI6111
    Software: NIDAQ6.9.3 with VisualC++
    Thanks in advance
    Michael

    Hi Michael,
    One of the possible causes of this error-10608 is a high update rate. The update rate might be high enough that you are not allowing enough time to fill the buffer with new data. This error can also be the result of having the regeneration option, within software, set to OFF. If you turn the regeneration option to ON, the error will go away. You can also reduce the update rate to see at which point you stop getting the error -10608
    I found the following links about errorcode -10843:
    http://digital.ni.com/public.nsf/websearch/EC38736BBF430DDC8625677C006F395C?OpenDocument
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RNAME=ViewQuestion&HOID=506500000008000000CA780000&ECategory=Measurement+Hardware.Digital+I%2FO
    regards
    TN

  • [ SOLVED ] Still not understanding how to reinstall Grub ?

    Hi All
    I currently have a dual boot windows 7 & Arch system and i have to wipe the Windows partition and reinstall.  But i am still confused as to how to reinstall Grub once i have reinstalled windows 7.  The wiki post is not longer available and have not found anything that explains what i need to do ... So can anyone point me in the right direction or explain what i need to do ?
    Many Thanks
    Last edited by whitetimer (2011-01-03 15:48:49)

    # FLAWLESS GRUB REINSTALL GUIDE BY DARKBEANIES ASSUMING YOU USE EXT3 FILESYSTEM
    # Boot arch install cd and login as root, and type the following commands in order, replacing X and Y values with the number of the partition/disk(MAKE SURE YOU GET THIS RIGHT, ASK IF YOU DON'T KNOW)
    cd /
    mount -t ext3 /dev/sdaX /mnt
    mount -t proc proc /mnt/proc
    mount -t sysfs sys /mnt/sys
    mount -o bind /dev /mnt/dev
    chroot /mnt /bin/bash
    #IMPORTANT-ONLY IF YOU HAVE SEPARATE BOOT PARTITION
    mount -t ext3 /dev/sdaX /boot
    #Then try:
    grub-install /dev/sdaX
    # -WHEN- this fails type this:
    grub
    root (hdY,X)
    setup (hdY)
    #Then reboot:
    cd /
    umount -a
    exit
    cd /
    umount -a
    reboot
    #That's it!
    Why oh why was this page removed from the wiki I do not know...
    Live CDs of various flavours available HERE: (Don't you have the CD or whatever you used to install to begin with?)
    http://www.archlinux.org/download/
    Last edited by darkbeanies (2011-01-02 17:24:55)

  • SMTP Banner mismatch - still not understanding how this works?

    I have a new Exchange 2010 install.  
    My outgoing email is getting flagged as spam.  MX Record test shows SMTP banner mismatch.
    I understand that you don't change the FQDN on the receive connector using the GUI.
    I have created an additional Receive connector so I have the following:
    Receive Connectors:
    Client Comm
    Default Comm
    My question is how to I change the smtp banner and which connector do I set it on.  The syntax needed for the Set-ReceiveConnector is kicking my butt.
    It sure is frustrating that the new Windows World is so centered around Powershell command lines. Very frustrating and backwards technology.
    The documentation on the Set and Get-Receiveconnectors is very poorly written. IMHO.

    My reverse DNS is setup correctly.
    This is an issue with the receive connector banner page.  Some email hosting services, AOL, Hotmail etc.  are flagging my outbound email as junk.  So they must be doing a test to see that my receive connectors have the wrong SMTP banner.
    My send connector is ALSO setup correctly.  
    I need help with the syntax in using the Set-receiveconnector cmd.
    Follow:
    http://technet.microsoft.com/en-us/library/bb125159(v=exchg.141).aspx
    Create a Internet type custom receive connector. My assumption is that you receive internet messages directly to the hubs. When you create an Internet Receive Connector it will allow anonymous senders to connect to it so it will work for internet messages. 
    In the Specify the FQDN this connector will provide in response to HELO or EHLO field, type the name advertised in response to the SMTP HELO or EHLO verb. If you leave this field blank, the fully qualified domain name (FQDN) of the Hub
    Transport server or Edge Transport server is automatically added when the connector is created
    Twitter!:

  • Still not understanding radial w/ transparency gradient

    I am trying to create the effect of a soft glow light behind a subject.
    I must be going dumb, but part of the problem is simply not "getting" the zen of doing gradients in PE, partly because everyone's very helpful suggestions seem to vary so widely on how to do it and I'm getting more confused.
    What I want to do is have one color (say dark red) where I can control its saturation, size, etc. and have everything else be transparent. I will be putting this graphic later on a website that has a colored background so I need the effect of the light being cast on that background.
    The more I try to learn gradients, the farther way the knowledge seems to be.
    Can anyone walk me through this?
    Thanks. 

    Tip: "delete" refers to hitting delete on the keyboard.
    http://www.pixentral.com/show.php?picture=1HpboRcB57ewPTvyui1MUeb9mI4WBR0
    This is as close as I can come to your request:
    Select background color 0,0,155 (can be any color, but this shows up well)
    File>new>blank file, 400px wide, 400px high, color mode RGB, resolution 300px/in
    Access Custom shape tool. In options bar set color to white, and in shape library for this tool select the triangle shape. Click on the little triangle at the top to get the shape geometry options. Select fixed size. Enter 260 px width, 225 px height. Click on canvas to create triangle.
    Now choose the oval shape in the library. Change geometry to 260 px wide, 50 px high. Click on canvas to create oval.
    Access move tool, and nudge oval into position at bottom of triangle with arrow keys  In layers palette, link the 2 shape layers and merge them (Layer>merge linked)
    Select foreground color red
    Select gradient tool, in options bar select foreground to transparent, linear gradient
    In layers palette, CTRL+left click the cone layer thumbnail to select it - should see marching ants
    Drag from south to north within the selection to to apply the gradient
    Select>deselect
    Here is a print screen to demonstrate the layer structure:
    http://www.pixentral.com/show.php?picture=10Hst6bjMVa0qFttqIBp9CI6ry5id
    Note the linked layers referred to above - #5
    If you finally need to delete the blue background for your purpose, you can do this readily utilizing the magic wand tool.
    HTH

  • Double buffering circle not round anymore

    I am making an applet where some circles are painted to the screen. When not using the double buffering scenario, the shapes appear correctly.
    The problem is when i use the double-buffering technique, the circles are still there, but they look like very ugly. I would call that some "squarcles".
    What is the bug here and how to get some decent double buffering with thoses circles?

    Ok, i had some problem with the running thread when closing the applet viewer, but now this situation is corrected by setting the animation thread to null before calling stop().
    Maybe explanation of the problem is not clear, so i made two versions of the same applet with only 2 lines of code different so that there is one applet that is not double buffered.
    You can check these by yourself at this place:
    Double buffered circles: http://www.geocities.com/xeneve/cooltrail/ demo_cooltrail.htm
    No double buffer:
    http://www.geocities.com/xeneve/cooltrail/demo_cooltrail_ndb.htm
    This is just annoying to get this result. I realise that maybe not many peoples are coding applets so i guess there is few people that may have a workaround for this.

  • Double buffering circle not round

    I am making an applet where some circles are painted to the screen. When not using the double buffering scenario, the shapes appear correctly.
    The problem is when i use the double-buffering technique, the circles are still there, but they look like very ugly. I would call that some "squarcles".
    What is the bug here and how to get some decent double buffering with thoses circles?

    Here is the code so far i have that is used for painting on the screen:
    // Declaration
    private BufferedImage ecran;
    private Graphics2D buffer_ecran;
    // Instantiation
    this.ecran = new BufferedImage(getSize().width, getSize().height, BufferedImage.TYPE_INT_ARGB);
    this.buffer_ecran = ecran.createGraphics();
    // In paint() method
    Graphics be = buffer_ecran;
      // Clean the surface
    be.setColor(Color.WHITE);
    be.fillRect(0, 0, getSize().width, getSize().height);
      // Draw the circles
    be.setColor(Color.RED);
    be.drawOval(x, y, ra, rb);
      // Output the buffer to the screen
    g.drawImage(ecran, 0, 0, this);I was previously using Image and changed to BufferedImage with the hope it would resolve the situation. I can't tell a significant change in image display.

  • I noticed this question has been asked a lot, but I still do not understand. How do I get my ALL of my iTunes music onto iCloud.  I have already subscribed to match and increased my icloud storage. Only some of my music is in the cloud, not on iphone

    I have noticed that this question has been asked a lot, but I am still not understanding. How do I move ALL of my music on iTunes into iCloud? I have subscribed to match and increased my iCloud storage. Only part of my music is in the Cloud and not on my iPhone.

    Hello, Crafter Lady. 
    Thank you for visiting Apple Support Communities.
    You may find this article helpful when troubleshooting issues with iTunes Match.
    iTunes Store: Troubleshooting iTunes Match
    http://support.apple.com/kb/ts4054
    Cheers,
    Jason H.

  • Latest version pf Keynote and still not working

    When i try to open a Keynote presentation on dropbox i get the text: download the newest version of Keynote. I have the newest version... Now what?

    About the latest version of Keynote and still not working
    I double checked that I´m using Keynote version 6 to open my presentation and still can´t open it. I worked on the presentation for about 7 days using the latest version and from one day to other I´m getting this problem. Any suggestion?

  • Why is CC not taking my password?  I changed it and it is still not accepting it.

    Why is CC not taking my password? I changed it, and it is still not accepting it.

    double check your adobe.com password, http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html

  • Problem with Double Buffering and Swing

    Hi
    I made a game and basically it works pretty well, my only problem is it flickers really badly right now. I read up on a whole lot of forums about double buffering and none of those methods seemed to work. Then I noticed that Swing has double buffering built in so I tried that but then I get compilation errors and I'm really not sure why. My original code was a console application and worked perfectly, then I ported it into a JApplet and it still works but it flickers and thats what I'm tryign to fix now.
    The code below is in my main class under the constructor.
    Heres the double buffering code I'm trying to use, I'm sure you all seen it before lol
    public void update(Graphics g)
              // initialize buffer
              if (dbImage == null)
                   dbImage = createImage(this.getSize().width, this.getSize().height);
                   dbg = dbImage.getGraphics();
              // clear screen in background
              dbg.setColor(getBackground());
              dbg.fillRect(0, 0, this.getSize().width, this.getSize().height);
              // draw elements in background
              dbg.setColor(getForeground());
              paint(dbg);
              // draw image on the screen
              g.drawImage(dbImage, 0, 0, this);
         }My paint is right under neath and heres how it looks
    This snipet of code works but when I change the method to
    public paintComponent(Graphics g){
    super.paintComponent(g)...
    everythign stops working and get a compilation error and says that it can't find paintComponent in javax.swing.JFrame.
    public void paint(Graphics g)
              super.paint(g);
              //if game starting display menue
              if (show_menue)
                   //to restart lives if player dies
                   lives = 3;
                   menue.draw_menue(g);
                   menue_ufo1.draw_shape(g);
                   menue_ufo2.shape_color = Color.DARK_GRAY;
                   menue_ufo2.draw_shape(g);
                   menue_ufo3.shape_color = Color.BLUE;
                   menue_ufo3.draw_shape(g);
                   menue_ufo4.shape_color = new Color(82, 157, 22);
                   menue_ufo4.draw_shape(g);
                   menue_ufo5.draw_shape(g);
                   menue_ufo6.shape_color = new Color(130, 3, 3); ;
                   menue_ufo6.draw_shape(g);
                   menue_turret.draw_ship(g);
                   menue_ammo.draw_ammo(g);
              else
                   //otherwise redraw game objects
                   gunner.draw_ship(g);
                   y_ammo.draw_ammo(g);
                   grass.draw_bar(g);
                   o_ufo.draw_shape(g);
                   b_ufo.draw_shape(g);
                   m_ufo.draw_shape(g);
                   s_ufo.draw_shape(g);
                   z_ufo.draw_shape(g);
                   xx_ufo.draw_shape(g);
                   info.draw_bar(g);
                   live_painter.draw_lives(g, lives);
                   score_painter.draw_score(g, score);
                   level_display.draw_level(g, level);
                   explosion.draw_boom(g);
         }I just want to get rid of the flickering for now so any help will be greatly appreciated. Depending which will be simpler I can either try to double buffer this program or port it all to swing but I'm not sure which elements are effected by AWT and which by Swing. Also I read some of the Java documentation but couldn't really understand how to implement it to fix my program.
    Thanks in advance
    Sebastian

    This is a simple animation example quickly thrown together. I have two classes, an animation panel which is a JPanel subclass that overrides paintComponent and draws the animation, and a JApplet subclass that simply holds the animation panel in the applet's contentpane:
    SimpleAnimationPanel.java
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Point;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.JPanel;
    import javax.swing.Timer;
    class SimpleAnimationPanel extends JPanel
        private static final int DELAY = 20;
        public static final int X_TRANSLATION = 2;
        public static final int Y_TRANSLATION = 2;
        private Point point = new Point(5, 32);
        private BufferedImage duke = null;
        private Timer timer = new Timer(DELAY, new TimerAction());
        public SimpleAnimationPanel()
            try
                // borrow an image from sun.com
                duke = ImageIO.read(new URL(
                        "http://java.sun.com/products/plugin/images/duke.wave.med.gif"));
            catch (MalformedURLException e)
                e.printStackTrace();
            catch (IOException e)
                e.printStackTrace();
            setPreferredSize(new Dimension(600, 400));
            timer.start();
        // do our drawing here in the paintComponent override
        @Override
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            if (duke != null)
                g.drawImage(duke, point.x, point.y, this);
        private class TimerAction implements ActionListener
            @Override
            public void actionPerformed(ActionEvent e)
                int x = point.x;
                int y = point.y;
                Dimension size = SimpleAnimationPanel.this.getSize();
                if (x > size.width)
                    x = 0;
                else
                    x += X_TRANSLATION;
                if (y > size.height)
                    y = 0;
                else
                    y += Y_TRANSLATION;
                point.setLocation(new Point(x, y)); // update the point
                SimpleAnimationPanel.this.repaint();
    }AnimationApplet.java
    import java.lang.reflect.InvocationTargetException;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    public class AnimationApplet extends JApplet
        public void init()
            try
                SwingUtilities.invokeAndWait(new Runnable()
                    public void run()
                        // construct the panel
                        JPanel simpleAnimation = new SimpleAnimationPanel();
                        // put it in the contentPane of the JApplet
                        getContentPane().add(simpleAnimation);
                        setSize(simpleAnimation.getPreferredSize());
            catch (InterruptedException e)
                e.printStackTrace();
            catch (InvocationTargetException e)
                e.printStackTrace();
    }Here's a 3rd bonus class that shows how to put the JPanel into a stand-alone program, a JFrame. It's very similar to doing it in the JApplet:
    AnimationFrame.java
    import javax.swing.JFrame;
    public class AnimationFrame
        private static void createAndShowUI()
            JFrame frame = new JFrame("SimpleAnimationPanel");
            frame.getContentPane().add(new SimpleAnimationPanel());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    createAndShowUI();
    }Edited by: Encephalopathic on Mar 15, 2008 11:01 PM

  • Double buffering still gives flickering graphics.

    I copied code from a tutorail which is supposed to illustrate double buffering.
    After I run it, it still flickers though.
    I use applet viewer, which is part of netbeans to run my applet.
    Link to tutorial: http://www.javacooperation.gmxhome.de/TutorialStartEng.html
    My questions are:
    Is the strategy used for double buffering correct?
    Why does it flicker?
    Why does the program change the priority a couple of times?
    Can you make fast games in JApplets or is there a better way to make games? (I think C++ is too hard)
    Here is the code:
    package ballspel;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import javax.swing.JApplet;
    //import java.applet.*;
    * @author Somelauw
    public class BallApplet extends /*Applet*/ JApplet implements Runnable {
    private Image dbImage;
    private Graphics dbg;
    private int radius = 20;
    private int xPos = 10;
    private int yPos = 100;
    * Initialization method that will be called after the applet is loaded
    * into the browser.
    @Override
    public void init() {
    //System.out.println(this.isDoubleBuffered()); //returns false
    // Isn't there a builtin way to force double buffering?
    // TODO start asynchronous download of heavy resources
    @Override
    public void start() {
    Thread th = new Thread(this);
    th.start();
    public void run() {
    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    while (true) {
    xPos++;
    repaint();
    try {
    Thread.sleep(20);
    } catch (InterruptedException ex) {
    ex.printStackTrace();
    Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    @Override
    public void paint(Graphics g) {
    super.paint(g);
    //g.clear();//, yPos, WIDTH, WIDTH)
    g.setColor(Color.red);
    g.fillOval(xPos - radius, yPos - radius, 2 * radius, 2 * radius);
    @Override
    public void update(Graphics g) {
    super.update(g);
    // initialize buffer
    if (dbImage == null) {
    dbImage = createImage(this.getSize().width, this.getSize().height);
    dbg = dbImage.getGraphics();
    // clear screen in background
    dbg.setColor(getBackground());
    dbg.fillRect(0, 0, this.getSize().width, this.getSize().height);
    // draw elements in background
    dbg.setColor(getForeground());
    paint(dbg);
    // draw image on the screen
    g.drawImage(dbImage, 0, 0, this);
    // TODO overwrite start(), stop() and destroy() methods
    }

    Somelauw wrote:
    I copied code from a tutorail which is supposed to illustrate double buffering.
    After I run it, it still flickers though.
    I use applet viewer, which is part of netbeans.. AppletViewer is part of the JDK, not NetBeans.
    ..to run my applet.
    Link to tutorial: http://www.javacooperation.gmxhome.de/TutorialStartEng.html
    Did you specifically mean the code mentioned on this page?
    [http://www.javacooperation.gmxhome.de/BildschirmflackernEng.html]
    Don't expect people to go hunting around the site, looking for the code you happen to be referring to.
    As an aside, please use the code tags when posting code, code snippets, XML/HTML or input/output. The code tags help retain the formatting and indentation of the sample. To use the code tags, select the sample and click the CODE button.
    Here is the code you posted, as it appears in code tags.
    package ballspel;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import javax.swing.JApplet;
    //import java.applet.*;
    * @author Somelauw
    public class BallApplet extends /*Applet*/ JApplet implements Runnable {
        private Image dbImage;
        private Graphics dbg;
        private int radius = 20;
        private int xPos = 10;
        private int yPos = 100;
         * Initialization method that will be called after the applet is loaded
         * into the browser.
        @Override
        public void init() {
            //System.out.println(this.isDoubleBuffered()); //returns false
            // Isn't there a builtin way to force double buffering?
            // TODO start asynchronous download of heavy resources
        @Override
        public void start() {
            Thread th = new Thread(this);
            th.start();
        public void run() {
            Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
            while (true) {
                xPos++;
                repaint();
                try {
                    Thread.sleep(20);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        @Override
        public void paint(Graphics g) {
            super.paint(g);
            //g.clear();//, yPos, WIDTH, WIDTH)
            g.setColor(Color.red);
            g.fillOval(xPos - radius, yPos - radius, 2 * radius, 2 * radius);
        @Override
        public void update(Graphics g) {
            super.update(g);
            // initialize buffer
            if (dbImage == null) {
                dbImage = createImage(this.getSize().width, this.getSize().height);
                dbg = dbImage.getGraphics();
            // clear screen in background
            dbg.setColor(getBackground());
            dbg.fillRect(0, 0, this.getSize().width, this.getSize().height);
            // draw elements in background
            dbg.setColor(getForeground());
            paint(dbg);
            // draw image on the screen
            g.drawImage(dbImage, 0, 0, this);
        // TODO overwrite start(), stop() and destroy() methods
    }Edit 1:
    - For animation code, it would be typical to use a javax.swing.Timer for triggering updates, rather than implementing Runnable (etc.)
    - Attempting to set the thread priority will throw a SecurityException, though oddly it occurs when attempting to set the Thread priority to maximum, whereas the earlier call to set the Thread priority to minimum passed without comment (exception).
    - The paint() method of that applet is not double buffered.
    - It is generally advisable to override paintComponent(Graphics) in a JPanel that is added to the top-level applet (or JFrame, or JWindow, or JDialog..) rather than the paint(Graphics) method of the top-level container itself.
    Edited by: AndrewThompson64 on Jan 22, 2010 12:47 PM

  • Double Buffering in Java Swing

    Hi sir,
    Here i want to know about what is exactly double buffering?
    I have learned that double buffering is automatic in swing components.
    But i have some problem with my JButtons it is FLICKERING a bit.Where u need to scroll the mouse to see it.Can be provide any idea for this.
    And also give some sample examples related to double buffering.
    Thanx,
    m.ananthu

    Hi sir,
    I have a problem with repainting and validate methods.
    In my project when i click a startbutton it will show a row of 4 buttons and when i click it again that 4 buttons should disappear.All this features are working well.But when i again click the startbutton
    the 4 buttons are not showing in the second time but when i use the
    mouse and scroll over 4 buttons area it is showing the 4 buttons.
    I have used repaint() and validate() methods still there is no use.
    so Pls. do help me.Is it any thing to do with double buffering ?It is
    Urgent.Here is my problem code:-
    Here is the code where MenuOptionList is a class that contains 4 buttons I have used the instance of the MenuoptionList here.Here when i click the "Start" which is for the start button Menuoptionlist will show which contains the row of 4 buttons as u can see there i have used a Flag=false for the first click (ie) to show the row of 4 buttons and in the next i have set the Flag=true to make the 4 buttons disappear all this features are working fine where jp.add(mol) means "jp" is a panel which is set it in the beginning of my home page with setBounds in to it i am adding the mol(instance of MenuoptionList).Here the problem is when i click the StartButton the 4 button are displaying & when i click it next time they are disappearing that all works fine.But when i click it for the next the 4 buttons should show.The problwem is they are showing but they are invisible in such a case if scroll the mouse over the 4 buttons area they are visible.What is the problem here.I have used repaint(),validate() methods still no use.Is the problem is to do with any instance removal.Pls.do help me.It is Urgent
    public void actionPerformed(ActionEvent e)
    changeCenterPanel(e.getActionCommand());
    private void changeCenterPanel(String buttonEvent){
    if((buttonEvent.equals("Start"))&&(Flag==false)){
    mol=new MenuOptionList(jp,jp1,jp2);//Which contains the 4 buttons
    mol.setBounds(150,1,500,600);
    Color c1=new Color(116,121,184);
    mol.setBackground(c1);
    mol.validate();
    mol.repaint();
    jp.add(mol);
    jp.validate();
    jp.repaint();
    Flag=true;
    else if((buttonEvent.equals("Start"))&&(Flag==true))
    mol.removeAll();//removing the 4 buttons
    mol.validate();
    mol.repaint();
    Flag=false;
    Thanx,
    m.ananthu

  • Speed of Swing versus double buffered AWT

    Hello
    I've noticed that drawing in a JPanel.paintComponent() takes about 4 times longer than drawing into an offscreen image in AWT Canvas.paint()
    Essential code excerpts follow
    // SWING, takes about 400 millis on my machine
    public void paintComponent(Graphics g) {
    g.setColor(Color.red);
    long startTime = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++)
    g.draw3DRect((int) (Math.random() * 200), 20, 30, 40, true);
    long endTime = System.currentTimeMillis();
    System.out.println("paintComponent() took " + (endTime - startTime) + " millis");
    // AWT, takes about 100 millis on same machine
    public void paint(Graphics g) {
    if (offscreenGraphics == null || offscreenImage == null) {
    offscreenImage = createImage(getWidth(), getHeight());
    offscreenGraphics = offscreenImage.getGraphics();
    long startTime = System.currentTimeMillis();
    if (offscreenGraphics != null) {
    offscreenGraphics.setColor(Color.red);
    for (int i = 0; i < 10000; i++)
    offscreenGraphics.draw3DRect((int) (Math.random() * 200), 20, 30, 40, true);
    g.drawImage(offscreenImage, 0, 0, this);
    long endTime = System.currentTimeMillis();
    System.out.println("paint() took " + (endTime - startTime) + " millis");
    Note that I also tried drawLine() instead of draw3DRect() and experienced similar results
    Can someone explain why doing this in Swing is so slow?
    I'd hoped to take advantage of Swing's double buffering, but I ended up using the same old offscreen image technique in Swing.
    Nick Didkovsky

    Silly question, but did you turn on double buffering or extend a Swing component which has it on by default?
    Not all of them do.
    : jay

  • HT4623 iOS 6.1 no longer available because you are no longer connected to the internet- this is what my iphone 4 shows. iv tried switching off again and again, closing apps by double tapping the home button but still not working. please help.

    this is what my iphone 4 shows. iv tried switching off again and again, closing apps by double tapping the home button but still not working. please help.
    is there any other method to download ios 6.1.2.
    my phone is not being recognized by itunes on my new windows 8. neither its working on touch copy.
    kindly help.
    thanks

    well in thatcase, i need another help .
    thanks for your instant reply.
    i have currently bought a new laptop (windows 8) and my iphone is not being recognized by itunes.
    because i have no backup on my previous laptop, i downloaded touchcopy but even touch copy is not recognizing my iphone.

Maybe you are looking for

  • How do I get my text messages on a new iPad?

    I traded iPads and only have today's text messages. I save EVERYTHING, especially my texts.  Can anyone help??

  • Adding Graphic Styles using VBA

    Hi all How would I go about applying graphic styles to a path using VBA? I would imagine the following line is wrong because it doesn't work.Any help would be appreciated. idoc.GraphicStyles("02-S").ApplyTo (isquare2)

  • Picture & Slideshow error message...

    www.wrdinc.net or web.mac.com/wrdinc i have several pages of pictures on my iWeb site. on most of the pages ("captured" "europe circa 2002" "the empire state") the pictures and slideshows display normally. On one page ("the happiest place on earth")h

  • Song won't play

    Downloaded a song, won't play, says authorize computer. Then says computer is already authorized

  • Loud Nat Sound

    Hello! Me and my best friend are making a film for a high school project and we're kind of in a bad way. The first interview we did we didnt think we would need to mic as we thought our camera had an ample enough mic of its own. Apparently we were we