Why does Swing not flicker?

Hi,
I have a JPanel that mixes some images painting and drawing ( all implemented in the paint() method). It works perfectly.
Then i have tried with a java.awt.Canvas and it started to flicker a lot.
Here the question: what does swing to remove the flicker, why it doesn't flicker??
Thanks

because Swing is already double buffered and AWT is not, you have to implement your own.
Google what is double buffered.
and by the way you don't override the paint method in swing you override the paintComponent method.

Similar Messages

  • Why does is not show the radio buttons

    I want to display the buttons in a row then radio button in a row under the button and then log scroll pane under the radio buttons. This is my code:
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(radioPanel, BorderLayout.CENTER);
            add(logScrollPane, BorderLayout.CENTER);When i run it it display the buttons and the logsrollpane. Why does it not display the radio buttons?

    Thanks guys.
    This is my problem. We have a big system that produce lots of log files and the software testers have to manually have to go through the logs file and look for a certain XML tags in the log file.
    What I want to do is help the software testers my developing a small tool that will allow them to open a log file and then click on a radio button corresponding to a xml tags that they are looking for and automatically highlight the tags in the file in yellow color .
    I am not sure how feasible this is and I am stuck.
    This is what I have done so far.
    Can you please guys help me go forward.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class FileChooserDemo extends JPanel
                                 implements ActionListener {
        static private final String newline = "\n";
        JButton openButton;
        JButton clearButton;
        JTextArea log;
        JFileChooser fc;
        // Radio Buttons
        static String em01 = "EM01";
        static String em07 = "EM07";
        /*static String dogString = "Dog";
        static String rabbitString = "Rabbit";
        static String pigString = "Pig";*/
        public FileChooserDemo() {
            super(new BorderLayout());
            //Create the radio buttons.
            JRadioButton em01Button = new JRadioButton(em01);
            em01Button.setMnemonic(KeyEvent.VK_B);
            em01Button.setActionCommand(em01);
            em01Button.setSelected(true);
            JRadioButton em07Button = new JRadioButton(em07);
            em07Button.setMnemonic(KeyEvent.VK_C);
            em07Button.setActionCommand(em07);
            //Group the radio buttons.
            ButtonGroup group = new ButtonGroup();
            group.add(em01Button);
            group.add(em07Button);
            //Register a listener for the radio buttons.
            em01Button.addActionListener(this);
            em07Button.addActionListener(this);
            //Put the radio buttons in a column in a panel.
            JPanel radioPanel = new JPanel(new GridLayout(0, 1));
            radioPanel.add(em01Button);
            radioPanel.add(em07Button);       
            //Create the log first, because the action listeners
            //need to refer to it.
            log = new JTextArea(40,60);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            JScrollPane logScrollPane = new JScrollPane(log);
            //Create a file chooser
            fc = new JFileChooser();
            //Uncomment one of the following lines to try a different
            //file selection mode.  The first allows just directories
            //to be selected (and, at least in the Java look and feel,
            //shown).  The second allows both files and directories
            //to be selected.  If you leave these lines commented out,
            //then the default mode (FILES_ONLY) will be used.
            //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            //fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            //Create the open button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            openButton = new JButton("Open File");
            openButton.addActionListener(this);
            //Create the save button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            clearButton = new JButton("Clear Text Area");
            clearButton.addActionListener(this);
            //For layout purposes, put the buttons in a separate panel
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            buttonPanel.add(openButton);
            buttonPanel.add(clearButton);
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(radioPanel, BorderLayout.LINE_START);
            add(logScrollPane, BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            //Handle open button action.
            if (e.getSource() == openButton) {
                int returnVal = fc.showOpenDialog(FileChooserDemo.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                     log.setText("");
                    File file = fc.getSelectedFile();
                    try{
                         BufferedReader in = new BufferedReader(new FileReader(file));
                             String data;
                             while ((data = in.readLine()) != null) {
                                  log.append(data + newline);
                    }catch(IOException ioe){
                log.setCaretPosition(log.getDocument().getLength());
            //Handle save button action.
            }else if (e.getSource() == clearButton) {
                  log.setText("");
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("PROGRESS Message Viewer");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new FileChooserDemo();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

  • Why does abode not work on my galaxy tab2

    Why does abode not work on my galaxy tab 2?

    The games dont load they just say I need to update to the latest version or say that it is not compaterble with it.

  • Why does sound not work on my Mac Air?

    Why does sound not work on my Mac Air --all setting seem okay. OSX 10.9.2 operating systyem.

    Open System Preferences > Sound > Output
    Make sure the coorect output devices is selected and the Mute button is not checked.

  • Why does 'User not registered for online use' show up when I try to import a cd into itunes. None of the cd info shows up either

    Why does 'User not registered for online use' show up when I try to import a cd into itunes? None of the cd info shows up either.

    Well, the format I upload from the camera is "video clip" or "video for Windows"...sometimes I've converted them to avi format, too. But as I said, it never even lets me get that far...I never get to even select a clip. As soon as I tell the program to "import/clip" it freezes up before I can even go to the folder that the clips are in. It has only begun to do this recently, and I'd never had any problems like this before. Last night I tried it again, and I clicked "open composition", and it froze when I did that too.
    I'm not sure how much more specific I can be about the details of the clips, since I'm positive it has nothing to do with the clips themselves...I'm running Windows XP, though...Home Edition Service Pack 2, Pentium 4 CPU 2.80GHz, with 504 MB of RAM. I have had the automatic updates turned on since I did my last reformat a couple of weeks ago. Could it have something to do with some kind of an update it may have done?

  • Put movies in itunes on one computer why does it not show up when i access itunes from other computers or ipad2?

    put movies in itunes on one computer why does it not show up when i access itunes from other computers or ipad2?

    i just purchased a file that had videos in it. i put them in the itunes library on my pc where i first downloaded them. i was able to transfer them to my other pc, a laptop, through my home network. i am now trying to get them on my mac pro desktop and my ipad2. my mac pro can see the other computers on my home network but i cannot get it to connect to them. i know the operating systems are different but was hoping i could transfer pictures and files from pc to mac this way. haven't been able to get it to work yet. the videos i am trying to get my mac to see came in a folder with both mac and pc versions. i thought if i got the videos i purchased into itunes that i would then be able to get them to my mac pro and my ipad2. i am new to mac/apple and have always been pc-centric so trying to marry it all has been difficult. i speak pc pretty well but am just learning apple. am i trying to do things that are not possible? i sure could use a knowledgable friendly soul to walk me through my issues of having pc and mac on the same network. i have been able to get all computers and ipad to print on my network. thanks.

  • HT204406 I have subscribed to match on iTunes and organized my music on my Mac Book.  Why does it not appear the same way on my iPad

    I would like my music to appear organized in the same way on my iPad as I have done it on my Mac Book.  (and on my iPhone as well)  Since it is in the cloud, why does it not appear the same way in all devices?

    The purpose of iTunes match is to make your music library available to all of your devices anywhere. It will sync Playlists, but no other type of organization you may have made.
    If you're having trouble, be sure you are logged into the same Apple ID on all devices but be sure to read this article and pay special attention to associating your devices with an Apple ID. There are important restrictions you should know about.

  • Why does lion not have front row

    why does lion not have front row
    and what can i do to get it i loved the ease of use

    Front Row is not included or supported in Lion.
    Read here, but proceed at your own risk

  • I just bought more icloud storage, why does it not let me backup my iPhone 5..says i need 1.4 GB of space

    i just bought more icloud storage, why does it not let me backup my iPhone 5..says i need 1.4 GB of space?..I just bought 10 more in icloud.

    I think you are confused. Syncing apps and music to your phone will not get store in the cloud by adding more cloud storage. If you don't have enough space to sync the music and apps, buying cloud storage won't help. If you have a 16GB phone, the phone still only has 16GB for apps and music even if you buy 10 mor GB of cloud storage.

  • Why does my screen flicker every 10-15 seconds?

    Why does my screen flicker every 10-15 seconds?

    like a blinking? do you have the late 08 MBP?
    if so go to system, energy saver, and select better performance. Your screen should be flicker free.

  • Why does TO_CHAR not like me adding a fraction then specifying FF?

    Why does TO_CHAR not like me adding a fraction?
    SQL> SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + .733409047, 'HH24:MI:SS') FROM Dual;
    TO_CHAR(
    17:36:07
    SQL> SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + .733409047, 'HH24:MI:SS.FF') FROM Dual;
    SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + .733409047, 'HH24:MI:SS.FF') FROM Dual
    ERROR at line 1:
    ORA-01821: date format not recognized
    -- NUMTODSINTERVAL() saves the day.
    SQL> SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + NUMTODSINTERVAL(.733409047, 'DAY'), 'HH24:MI:SS.FF') FROM Dual;
    TO_CHAR(TO_TIMESTA
    17:36:06.541660800

    Hi,
    Date arithmetic only works with DATEs.
    If you want to do something similar with TIMESTAMPs, use NUMTODSINTERVAL:
    SELECT  TO_CHAR ( TO_TIMESTAMP ('1/1/2012', 'DD/MM/YYYY') + NUMTODSINTERVAL (.733409047, 'DAY')
              , 'HH24:MI:SS.FF'
    FROM      dual
    ;Here's exactly what's happending:
    When you say "d + n", d is supposed to be either a NUMBER or a DATE. When you pass any other datatype, Oracle tries to convert d to either a NUMBER or a DATE. In this case, d was a TIMESTAMP; Oracle realized that it could convert that TIMESTAMP into a DATE, and did so. The 1st argument to TO_CHAR, therefore, was a DATE, but '.FF' only works with TIMESTAMPs.
    There are a couple of things about how Oracle handles this that I find annoying, but I don't know of any better work-around.
    Edited by: Frank Kulash on Feb 16, 2012 1:39 PM

  • Why does Apple not give a list of error messages and possible solutions? I have the (-54) error continually that has suddenly appeared and cannot find a solution, even though other users seem to have the same problem.

    Why does Apple not give a list of error messages and possible solutions? I have the (-54) error continually that has suddenly appeared and cannot find a solution, even though other users seem to have the same problem.

    This is a user to user forum.  Apple isn't here and won't answer you.  You need to contact Apple directly.  You can use the Contact button at the bottom of the screen.

  • Why does cellular not support phone features?

    iPad Mini with Retina display has a celluar capability. Why does it not support full phones features, doubling as an iPad and phone like the iPhone 5S does?

    And I don't mean to seem rude. I have worked in product development many years with a very large company. I have also challenged engineers and developers to look beyond the basics to deliver something that sets the trend adn differentiates itself from the pack.
    Apple as that trend-setter created awesome products in the form of the iPad Air and the iPad Mini w/ RD. It is extraordinary in the leading technologies they incuded in the  package. It would have been BRILLIANT though, to have converged both as an IPad and a phone. It would have propelled the iPad light years ahead of the competition.

  • After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    After Effects CC 2014 will not upgrade?  Gets to 100% and then says application failed.  Why does this not upgrade?

    We can't know anything. You have not provided any useful details like system information or the install logs.
    Mylenium

  • Why is my wi-fi greyed out?  Why does battery not hold charge for more than a few hours?  All since IOS7.

    Why is my Wi-Fi greyed out?   Why does battery not hold a charge longer than a few hours?  All since upgrade to IOS 7.

    To validate the operating system and radio software complete the following steps:
    Tap Settings > About.
    In the Category drop-down menu, select  OS.
    Ensure the Radio Version is only 1 number higher than the  OS Version.
    If not then follow this
    http://www.blackberry.com/btsc/KB34666
    Click here to Backup the data on your BlackBerry Device! It's important, and FREE!
    Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up
    Click to search the Knowledge Base at BTSC and click to Read The Fabulous Manuals
    BESAdmin's, please make a signature with your BES environment info.
    SIM Free BlackBerry Unlocking FAQ
    Follow me on Twitter @knottyrope
    Want to thank me? Buy my KnottyRope App here
    BES 12 and BES 5.0.4 with Exchange 2010 and SQL 2012 Hyper V

Maybe you are looking for

  • Calling RFC Function module from JAVA

    Hi All,    We have created a RFC Function Module for Billing Plan tab in Sales order (BDC). The function Module contains BDC. When we are running the same function module in SAP it is working fine. But when the FM is called in Java , it is allowing o

  • Is there any way to set an image from your camera roll as a wallpaper without having a shadow over it on iOS7?

    Everytime you set a picture from Camera Roll as a wallpaper a dark shadow appears on the top and the bottom of the image. Is there anyway one can turn this off? I've noticed this doesn't happen with the preset wallpapers the phone brings.. Thanks Any

  • Customer Communication Preferences - Do Not Call & Do Not Email

    Oracle leverages Siebel CRM to develop an effective solution to address the Do Not Call and Email Permissible Use requirements. The application uses the Contacts functionality to manage communication preferences, which when defined, centrally synchro

  • Play a local file using URLDataSource

    Hi, I need to play a local video file using URLDataSource, but i dont know why im getting the next error: Error loading the video: NoPlayerException. Cannot find a player. But, with a file video on internet it works perfectly. import javax.media.prot

  • Photoshop images from negs/slides sent via email

    this could also be a mac problem? I scanned b/w negs and also colour slides and made adjustments to the pictures in photoshop. All  looks just fine. But when emailing the finished files as tiffs , the email receiver  then tried to saved from the mail