What is the best way to double buffer in this case and how to do it....

currently I have
public class Frame1 extends JFrame{
//inside this class I call up circle class, rectangle class, etc.... to draw
}I am making a "paint" program, and I have individual classes to handle the paint methods heres an example:
abstract public class Shape {
    public Shape() {
    public abstract void draw(Graphics g, Color c, int x, int y, int width,int height);
}and then....
public class Circle extends Shape{
    public Circle() {
    public void draw(Graphics g, Color c, int oldx, int oldy, int newx, int newy) {
        g.setColor(c);
        g.drawOval(Math.min(oldx, newx), Math.min(oldy, newy), Math.abs(oldx - newx), Math.abs(oldy - newy));
}There is also a Rectangle class, line class.... etc! So my question to you is the following... what is the best way to implement double buffer in the individual classes? And how to do it?? And also.... the drawings should be kept inside a jPanel.
Any bit of help is much appreciated Thank you!!

You don't need to do double-buffering. Swing
components are double-buffered by default. Just make
sure you override paintComponent() and not paint().
And even if you had to, why would there be any
difference in implementation for your classes whether
they paint to on- or off-screen graphics?I need to override paintComponent()? what if I don't...
I am using JBuilder2005 and they automate somethings for me. So thats how they did it when they created the application they did this....
public class Frame1 extends JFrame{
/*** all my code here***/
public class Application1 {
    boolean packFrame = false;
     * Construct and show the application.
    public Application1() {
        Frame1 frame = new Frame1();
        // Validate frames that have preset sizes
        // Pack frames that have useful preferred size info, e.g. from their layout
        if (packFrame) {
            frame.pack();
        } else {
            frame.validate();
        // Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        frame.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
     * Application entry point.
     * @param args String[]
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.
                                             getSystemLookAndFeelClassName());
                } catch (Exception exception) {
                    exception.printStackTrace();
                new Application1();
    private void jbInit() throws Exception {
}

Similar Messages

  • What is the best way to back-up my entire library, and How??

    I need to back up my library before somethings happens!!  What is the best way to do that?  Also how do you restore it back on your itunes???

    My 2 cents...
    Fast backup for iTunes library  (Windows)
    Grab SyncToy  2.1, a free tool from MS. This can be used to copy your entire iTunes library (& other important data folders) onto another hard drive or network share. You can then use SyncToy periodically to synchronise or echo your library to the backup. A preview will show which files need to be updated giving you a chance to spot unexpected changes and during the run only the new or updated files will be copied saving lots of time.
    If your media is all organised below the main iTunes folder then you should also be able to open the backup library on any system running the same version of iTunes, regardless of the drive letter or path it appears on.
    Step-by-step install guide
    You restore files simply by copying them back to where they are missing from, or copy back the entire folder in the event of a major disaster.
    tt2

  • What is the best way to do a 10.8 reinstall and keep all of my data?

    What is the best way to do a 10.8 reinstall and keep all of my data?

    Boot to the recovery disk and reinstall the os. That said you do have a back up just in case (I trust)?

  • HT5621 My husband and I both have iPhone 5. We currently share the same apple I'd. How do we get separate ones. Him keeping his and me getting a new one? What is the best way to go about doing this?

    My husband and I both have iPhone 5. We currently share the same apple I'd. How do we get separate ones. Him keeping his and me getting a new one? What is the best way to go about doing this?

    FAQ apple id http://support.apple.com/kb/HT5622?viewlocale=en_US

  • Should the admin/user folder and all of its sub folders be moved to the hdd or just parts of it? (eg. picture, movies, documents)  What is the best way to go about doing this.  Also should a 2t hdd be partitioned.

    iMac with 256ssd and 2t hdd. Should the admin/user folder and all of its sub folders be moved to the hdd or just parts of it? (eg. picture, movies, documents)  What is the best way to go about doing this.  Also should a 2t hdd be partitioned.

    Yes, you can move your user directories to the HD and keep your OSX and Applications on the SSD drive.
    Whether you partition your HD or not depends on how much data you have and how you propose to use your HD.
    Are you planning to use your iMac as a Time Machine backup volume? If so, partition it off.
    Do you have huge data files, eg video, music, photos?
    How much of your 2tb drive will be "free" once it is loaded with all your data?
    A little more information is required before the optimal configuration can be recommended for your use.

  • What's the best way to merge, restore or reconstruct iPhoto and Aperture libraries to resolve images that are not found/offline?

    Hey there, Apple Support Communities.
    To start, I'm working on a MBP Retina 15" with a 2.3GHz i7 processor and 16 GB of RAM.  10GB free on a 256GB SS HD.  Attached are two external HDs - one 1TB Western Digital portable drive from 2011, one 2TB Porsche LaCie non-portable drive from 2013; both connected via USB.  All photo libraries in question are on the external drives.
    I have Aperture 3.5.1 and iPhoto 9.5.1.  I prefer to work in Aperture.
    The Issue(s)
    Over the years, I have accumulated a number of iPhoto libraries and Aperture libraries.  At one point, I thought my WD drive was dying so I purchased the LaCie and copied all libraries over the the LaCie drive.  (Turns out, there's probably an issue with my USB port reading drives, because I can once again see the WD drive and occasionally I can't see the LaCie drive.)
    So now I have old version of some libraries on the WD drive, and new versions on the LaCie drive.
    When I was moving things, I ran the software Gemini to de-dupe my iPhoto libraries.  Not sure what effect that may have had on my issues.
    In my main Aperture library and in some iPhoto libraries, I get the image-not-found badge or exclamation point.  I've dug through the hidden Masters folders in various libraries to find the original image.  In some cases, I have been able to find the original image, sometimes in a different version of the iPhoto library.
    My Question(s)
    1.  For Aperture libraries that have missing originals, is there some magical way to find them, or have they just disappeared into the oblivion?
    2.  For iPhoto libraries that have missing originals and I have found the original in another iPhoto library, what is the best way to proceed?
    3.  Are there quirks to merging iPhoto and Aperture libraries (by using the Import->Library) feature that I should be aware of?
    TL;DR: Too many iPhoto and Aperture libraries, and not all the original pictures can be found by the libraries anymore, though some originals still do exist in other libraries.  Steps/process to fix?
    Thank you!  Let me know if you need add'l info to offer advice.
    With appreciation,
    Christie

    That will not be an easy task, Christie.
    I am afraid, your cleaning session with Gemini may have actually removed originals. I have never used this duplicate finder tool, but other posters here reported problems. Gemini seems to replace duplicate original files in photo libraries by links, and this way, deleting images can cause the references for other images to break. And Aperture does not follow symbolic links - at least, I could never get it to find original files this way, when I experimented with this.
    1.  For Aperture libraries that have missing originals, is there some magical way to find them, or have they just disappeared into the oblivion?
    You have to find the originals yourself. If you can find them or restore them from a backup, Aperture can reconnect them. The reconnect panel can show you, where the originals are supposed to be, so youcan see the filename and make a Spotlight search.
    For iPhoto libraries that have missing originals and I have found the original in another iPhoto library, what is the best way to proceed?
    Make a copy of the missing original you found in a folder outside the iPhoto library. You can either open the iPhoto library in Aperture and use "File > Locate Referenced file" to reconnect the originals, or simply reimport them. Then Lift&Stamp all adjustments and metadata to the reimported version.
    See this manual page on how to reconnect originals:  Aperture 3 User Manual: Working with Referenced Images  (the paragraph:  Reconnecting Missing or Offline Referenced Images)
    Are there quirks to merging iPhoto and Aperture libraries (by using the Import->Library) feature that I should be aware of?
    References images will stay referenced, managed will remain managed. You need to unhide all hidden photos in iPhoto - this cannot be done in Aperture.
    and not all the original pictures can be found by the libraries anymore, though some originals still do exist in other libraries.  Steps/process to fix?
    That is probably due to Gemini's replacing duplicate originals by links, and your best cause of action is to fix this before merging the libraries. Reconnecting can be done for your iPhoto libraries in Aperture.

  • What is the best way to get rid of troyan virus and safari virus?

    what is the best way to get rid of viruses on my macbook?  the viruses are causing popups and saying that the device is infected.

    ds store wrote:
    ClamXav is only a scanner, it can't remove the MacDefender malware.
    Yes, it can. ClamXav scans and quarantines it. It was updated.
    http://www.reedcorner.net/news.php/?p=98
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 

  • What is the best way to run internet explorer on Mac and IPad and is it safe to do so??

    I need to run internet explorer to access new billing software,  what is the best way to do so and is it safe to run this on macbook and ipad if possible??

    You can't run IE on an iPad and the only way to use it on a Mac, since it's been discontinued for years for the Mac OS, is to install Windows either via Boot Camp or via running Windows as a virtual machine using something such as Parallels Desktop (my personal preference).
    Clinton

  • What is the best way to take a cluster, unbundle it, and output to controls?

    I have a sub-VI with a cluster of controls coming into it. After I get the cluster into the sub-VI what is the best way to unbundle it and apply the values to the controls in the sub-VI? I am trying to stay away from unbundling it and then wiring a local variable of each control to the unbundled name. What other ways are there of performing this type of operation? Thanks in advance for any help.
    Troy

    Hi Troy,
    well you could work with clusters directly. This way there is no need to unbundle and bundle again...
    Otherwise you can work like this to change values in a cluster:
    (Yes I know, the code is quite senseless...)
    Message Edited by GerdW on 07-26-2007 04:21 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    cluster.png ‏2 KB

  • What's the best way to backup all of my music and pictures?

    I have a Mac Mini with the Super Drive and i was woundering which is the best way to back all of the music that i have bought from iTunes and pictures i have in iPhoto, that way in case my Hard Drive crashes or i buy a new Mac Mini i can just transfer the files onto the new Hard Drive, is buying a iPod Video or a external hard drive be the best thing to do or can i just burn everything on a DVD-R?
    Thank you.

    Wow, that sounds pretty easy, just drag and drop, but what exactly did you mean when you said "When restoring your data, ensure that all the iTunes and iPhoto files are restored before launching those applications"
    What i was going to do is just copy (restore) all the data onto a external HD or a DVD-R and then make sure iTunes and iPhoto still has the same number of files and then i would check the DVD-R or the external HD to make sure that the files have been copied, right?
    One more question, most of my music on iTunes was bought from the iTunes Music Store, will it still copy?

  • What is the best way to store data for this project?

    hey everyone,
    I have been subscribed to this for a while, not sure if I have ever actually asked anything though.
    I have a project on the go for myself/portfolio
    It is a booking sheet, where by I have a GUI that has a diary system of a day followed by time slots. This also has a date picker that can change the date of the booking sheet
    I want to be able to store mainly strings and ints,
    I need to be able to store, retrieve and on occasion change some data.
    I was looking at using something called JExcelAPI but I cant get that to work at all, I asked for assistance but was refered to here.
    what would be the best way to implement this data storage?
    davyk

    Hey everyone,
    Back again,
    I got this this little snippet of code working but want to ask you guys for a little bit of help on it. if thats ok?
    try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         String dataSourceName = "mdbTEST";
         String dbURL = "jdbc:odbc:" + dataSourceName;
         Connection con = DriverManager.getConnection(dbURL, "","");
         // try and create a java.sql.Statement so we can run queries
         Statement s = con.createStatement();
         s.execute("create table TEST1234567 ( column_1 char(27), column_2 char(150), column_3 char(150), column_4 char(150), column_5 char(150), column_6 char(150))"); // create a table
         s.execute("insert into TEST1234567 values('"+date+"','"+a+"','"+b+"','"+c+"','"+d+"','"+e+"',)"); // insert some data into the table
         s.execute("select column_7 from TEST1234567"); // select the data from the table
         ResultSet rs = s.getResultSet(); // get any ResultSet that came from our query
         if (rs != null) // if rs == null, then there is no ResultSet to view
                    while ( rs.next() ) // this will step through our data row-by-row
              /* the next line will get the first column in our current row's ResultSet
              as a String ( getString( columnNumber) ) and output it to the screen */
                   System.out.println("Data from column_2: " + rs.getString(1) );
         s.execute("drop table TEST1234567");
         s.close(); // close the Statement to let the database know we're done with it
         con.close(); // close the Connection to let the database know we're done with it
    catch (Exception err)
         System.out.println("ERROR: " + err);
         err.printStackTrace();
    }there are more columns, but i cut this code down.
    my question is:
    I think I want a method with an if statement to see whether the table is created or not, if not create it, but how do I go about this? I have searched the API and google, but my brain is fried.
    Also do I always have to do the try/catch and have the code of Class.forname to Statement s in all methods that want to deal with the table?
    davy

  • What is the best way to protect my info in case my iPad is stolen

    Ideas for the best way to protect my info I'd my iPad is stolen or lost?

    I also had my iPad stolen, and thats when other troubles started! I received an email on my PC stating that my iTunes password had been reset.  The thief had done this!  So I rang the Apple help line to ask what to do. they said just reset the password, and as the thief couldnt access my emails it would be okay,,the Apple emails also suggested this.   But that was the issue that stupid me hadnt realised!!! As the iPad was receiving my emails the the thief could easily reset the iTunes password , and download muic and videos on my credit card on iTunes!!         As happened to me.
    Apple does not warn you of this possibility, even when i spoke to their Help line. And searched their website for advice
           So, my advice is, Do Not store your email password on your iPad, and  maybe, do not leave your credit card details with iTunes? An irritation I know! If you have not done these things, then if your iPad is stolen then immediately change your email password, and stop your iTunes credit card.
         Probably iTunes need a safer way to change passwords, like an sms code to allow password changes, as relying on emails is not safe, as the thief will frequently be receiving those emails too!!!

  • What is the best way to extract/consume HR data to and from Peoplesoft?

    I have to do integration between Peoplesoft and Oracle ERP to send HR data from Peoplesoft to Oracle HRMS. I will use Oracle Fusion Middleware for building the interface. I don't have much experience in working with Peoplesoft tools, like PeopleTool, App Engine, Integration Broker, Component Interface and Oracle adapter for Peoplesoft. Can somebody please let me know what is the most popular or recommended or best way to extract HR data from Peoplesoft.
    The second interface will consume some HR data from Oracle. Once again I need to know different ways to insert data into Peoplesoft.
    I appreciate if you can share your experience for the above two scenarios.

    If you plan on buying a apple laptop you have two options. You can use time machine or pull the data off of it directly and put it onto the external. I advise the second choice. This way you do not have stuff that you dont need filling up the space on your new drive. Get your applications, music, documents, photos, videos and perhaps downloads and desktop; Put all of these on your external. And then reinstall osx onto your drive.
    *** If buying a windows machine next check the format of the drive in disk utility. You will need a program called Paragon NTFS to format the drive window compatibility. You have to pay for the free version but can download a trail version for free.
    http://www.paragon-software.com/home/ntfs-mac/
    Did i leave anything unanswered?

  • I have created a 12 minutes slideshow on imovies and on idvd.  I want to show it to my relatives in Europe.  What is the best way for me to do this? utube?

    I have created a 12 minute slideshow on imovies and burned it through idvd.  I would like to share it with my relatives in Europe. what would be the best means of doing this? uTube? any other ideas?

    You could put it on Youtube, but then they don't have a cop saved to their drive. You could also upload it to your Dropbox and make it public. Note the size of the file, Dropbox and Youtube can only handle such big files, and if your family has a good internet connection (download/playback speeed over bandwith).

  • What is the best way to SSO custom Tomcat J2EE, Sharepoint and Portal?

    We are implementing EP7.0 and I believe we can use logon tickets and SAPSECULIB to integrate all our infrastructure which is Sharepoint (Runs on IIS), our custom J2EE applications (run on Apache webserver and Tomcat).
    Is using of logon tickets and SAPSECULIB the recommended way to accomplish SSO or is there a better way?
    Thanks in advance

    Hi Victoria,
    I would put the html file that you generated on the file system
    let say the Apache/Apache/htdocs
    Then I'd put an HTML portlet on the page and show the HTML file using an iframe
    <iframe src="name of your file"
                height="600"
                width="800"
                frameborder="0"
                scrolling="no"
    </iframe>Hope this helps.
    Cheers
    Diego

Maybe you are looking for

  • Error Executing query in web template

    Hi, We recently upgraded to Nw2004s. When i'm executing my query i'm getting below error message Technical Information for Message: Activate the ZCRM_IS01 InfoCube/InfoProvider Again  Notification Number BRAIN 056  When i activated the infoprovider w

  • Recording video from iPhone straight to Macbook

    I am using my iPhone 5 a lot for video recording purposes. A times when recordin my space will fill up and stop the recording. Is there a way to connect my iPhone to my Macbook and have video record straight to my Macbook instead of constantly upload

  • Safari pop-up EXCEPTION list

    I bet I am not the only on who wants an "exception list" to allow pop-ups. The current solution is "all or nothing". I am aware this is for security reasons but some radio stations for instance when accessed via tunein (which is my preference) requir

  • Enhanced workflow creation in Captivate 7

    What is the process for creating a workflow in Captivate 7? Thank you for your help.

  • Running multiple weblogic servers on the same JVM

    Is there a way to make Weblogic 7.0 and Weblogic 5.1 run on the same JVM? If so what are the pros and cons?