When/Why to use Canvas?

Okay, so I'm looking into creating custom components and I know that Canvas class was made to give programmers a class to use solely for drawing. However, you could just use JComponent/Component to creat custom buttons, menu's, etc. So I'm a little confused why we have Canvas and what the best way is to go about making a custom component, graphically.

LavaJava wrote:
Okay, here's another point to bring up since you said don't mix awt and swing. Things like graphics and graphics 2d are under awt but to my knowledge there is no equivalent in swing. This all may seem confusing at first, but the more you play with it, the more you read on it, the more it will make sense. Morgalr and Darryl are as usual right on the money. As they state, Swing is built on top of AWT, however they are very different in how they display components. While AWT uses the native OS to render its buttons, panels and other widgets, Swing renders these things internally, all except the root container such as the JFrame (I believe). This gives Swing much greater flexibility in how it displays these things and how you can change and control them. Because of these differences though, it is generally not safe to display Swing widgets together with AWT widgets. There are as always exceptions, but you have to have a darn good reason to claim an exception (you don't), and have to have the smarts to be able to mingle the AWT and Swing widgets together (I don't).
Also, for some odd reason, JFrame is in swing package but it's hierarchy is under awt. In fact, that very fact about JFrame has give me problems when trying to do keybindings on a JFrame.Then don't do key bindings on the JFrame. Do it instead on one of the JComponents it holds. You do know that even the contentPane is at its heart a JComponent (though this needs to be casted if you want to use it directly).
Good luck,
Pete

Similar Messages

  • When & Why to Use WL Adapter for MQSeries as compared to MDB?

              We have a need to both send and receive message via MQSeries in asynch mode.
              Initial assessment was to receive messages via MDB and send messages by use a
              pool of Sessions to the MQ Mgr connection.
              Given this why should one use WL Adapter for MQ?
              Thanks
              Tariq.
              

    I assume you are referring to the "WLI" adapter? Perhaps try posting
              your question to the "weblogic.integration.developer" or
              "weblogic.integration.interest" newsgroup.
              If you are referring to the "Messaging Bridge", which comes with
              WebLogic server, then the advantage is that MQ need not be up for the
              senders to continue sending. Senders can send messages to a WebLogic
              queue, which the bridge can in turn forward to an MQ queue. The
              disadvantage is that the extra bridge hop may slow down your app.
              Tom, BEA
              P.S. You are likely by now aware that WL 8.1 (just released in beta),
              can automatically pool foreign (or WebLogic) sessions for you.
              Additionallly, it provides help in that you can configure wrappers for
              foreign JMS objects. See "Accessing JMS Foreign Providers" and
              "Accessing JMS via Servlets and EJBs" listed under new features:
              http://e-docs.bea.com/wls/docs81/notes/new.html#1125379
              Tariq Bhatti wrote:
              > We have a need to both send and receive message via MQSeries in asynch mode.
              > Initial assessment was to receive messages via MDB and send messages by use a
              > pool of Sessions to the MQ Mgr connection.
              >
              > Given this why should one use WL Adapter for MQ?
              >
              > Thanks
              > Tariq.
              >
              

  • Why do I keep getting an error message when trying to use passbook?

    Why do I keep getting an error message when trying to use passbook?

    Kind of hard to answer without some details such as iPhoto version and OS version. Are you signed into your Facebook account?

  • Why am I getting an error message when trying to use a template?

    Why am I getting an error message when trying to use a Pages template?

    You are getting an error message because there is an error.
    Knowing wht version of Pages you are using, what template you are attempting to open, and what error message Pages is sending you might help determine why you are getting that specific rror message. Without those, the first sentence above i pretty much all that can be said with any assurance.
    Regards,
    Barry

  • Why do I get this error when trying to use my bluetooth headset as a listening device? There was an error connecting to your audio device. Make sure it is turned on and in range. The audio portion of the program you were using may have to be restarted.

    Why do I get this error when trying to use my bluetooth headset as a listening device? There was an error connecting to your audio device. Make sure it is turned on and in range. The audio portion of the program you were using may have to be restarted.

    I may have already resolved this issue buy removing the device from my computer and re-pairing it. It is currently working just fine.

  • Why to use B2B when we can go with ...

    why to use B2B when we can go with A2A with FTP services running in the source and target systems.
    why do we go for parties if the above one is possible.
    plz help out im into loads of confusion

    Hi
    A2A is application to application: when two applications in a company talk to each other we call it an A2A scenario and if its across Companies we call it B2B or buisness to buisness scenarios.
    All the following links will explain   the difference between A2A and B2B
    With scenario’s
    A2A   B2B Scenarios
    can anyone explain A2A & B2B  AND  BPM & ccBPM  with an example..
    Help for Scenario! B2B or A2A
    A2A Vs B2B
    A2A and B2B
    I hope this will answer your question
    regards
    --- prasad

  • I used my friend itune to transfer songs to my iphone 4 but when i am using itunes from my laptop i am not able to tranfer songs to iphone.. but from my friends laptop is working.. why and what need to do ?

    I used my friend itune to transfer songs to my iphone 4 but when i am using itunes from my laptop i am not able to tranfer songs to iphone.. .. why and what need to do ?

    I would suggest that join your iphone with iTunes and do not sync. Than in your info window of iTunes uncheck auto sync of songs and videos. Check Mark for manual selection of songs. Also uncheck sync of songs window. After this sync your iphone and manually copy your songs from your iphone through itune by opening music under your iphone icon in the left status bar and copy to your laptop music folder. I think it would help out.  I did same for myself. Try out. TC

  • Why and when can I use the "NotBoundException" in my RMI?

    why and when can I use the "NotBoundException" in my RMI?

    The answer to this is contained in the documentation which you should have read before posting to this forum.

  • Why do I still hear sound through speakers when I'm using ear buds?

    Why do I still hear sound through speakers when I'm using ear buds?

    likely same issue just the detector is stuck in the opposite setting
    https://discussions.apple.com/thread/1343532

  • Why is the volume so low on my iMac when I'm using Safari?

    Why is the volume so low on my iMac when I'm using Safari?
    On both my 2008 MBP and my new 2014 iMac 27" when I listen to the audio portion of a streaming video or news story using Safari, I can hardly hear anything. I have to crank the volume all the way up just to barely hear what is being said. Any ideas on how to fix this?

    please help!! I have the new 2014 iMac 27" as well, same thing happen to me. Dont know what to do!

  • I have seen on this community that the earpods do not work on iPod shuffle gen 3 but when I was using on them it worked the control panel thing that is but only until I turned it off I don't understand why it won't work again and why it did in the first p

    I have seen on this community that the earpods do not work on iPod shuffle gen 3 but when I was using on them it worked the control panel thing that is but only until I turned it off I don't understand why it won't work again and why it did in the first place can someone please explain and tell me how to make it work again

    Sorry first time asking question didn't mean to write same thing twice well copy paste

  • Why Can't I use BT when I am using the wireless Network?????

    Why Can't I use BT when I am using the wireless Network?????
    I am using airport extreme.....

    In an inline renderer, the compiler knows which document will be the “outerDocument” so it sets up special code to assign that value.  I think you can use parentDocument or owner.document

  • Why can´t I use inport VI in win xp even when I have used userport aplication?

    why can´t I use inport VI in win xp even when I have used userport aplication for enabling port reading in this plattform?, I´m getting data from the parallel port in epp mode, my pc´s pararell is ok bcs I can read data in c++

    If you have an older LabVIEW (6.1 or earlier) you will need to exchange the in port and out port VIs that came with LabVIEW with different ones and install a DLL. The reason is documented here . This link (which is the first link returned when you search ni.com for "in port") explains basically that the OS won't let you until you have kernel level access. The devzone link at the bottom of the refered page will include all of the code that you need to install (VIs and DLL) to make it work.
    >
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • Why or When should we use Execute Immediate in PLSQL??

    Hi Frnds,
    Long Ago i have received a interview question that ...
    How can U create a table in the PLSQL object(Function or procedure)?
    But the thing y should we use execute immediate?
    In which scenario we should we should use????????????
    Why or When should we use Execute Immediate in PLSQL????

    OR
    http://stackoverflow.com/questions/18375990/oracle-what-does-execute-immediate-means
    For DML you'd use it when running statements that you don't have available at compile time, e.g. if the column list is based on a selection from the user.
    In your case it's being used because DDL cannot be run as static SQL from within PL/SQL. Only certain query, DML and TCL commands are valid. Anything else has to be treated as dynamic.
    I'd say it's rare to need to use DDL from a PL/SQL block. TRUNCATE might be reasonable; if you find anything creating or dropping objects on the fly then that might be more of a concern as it can suggest a suboptimal data model.
    EXECUTE IMMEDIATE itself does not automatically commit; but if you execute DDL then that will behave the same as if you ran it outside PL/SQL, so it will commit in your case, yes.
    Incidentally, I'm not sure why your code is using an intermediate variable to hold the statement; that's useful if you want to display what it's going to run maybe, but you don't seem to be doing that. What you have could be done as:
    EXECUTE IMMEDIATE 'TRUNCATE TABLE BD_BIDS_EXT_DET';
    Thank you

  • Why do I need to set up sync when I only use 1 computer. A warning showed up that says: Sync encountered an error while connecting: Unknown error. Please try again.

    When I started up my computer this morning, a warning popped up saying: ! Sync encountered an error while connecting: Unknown error. Please try again.
    Why do I need to set up Sync on Firefox when I only use this one computer and do not even have a cell phone?

    If you do not want to use Firefox Sync any more, you can deactivate it. See instructions here: [[How do I manage my Firefox Sync account?]]

Maybe you are looking for