4 Replies Latest reply: Nov 25, 2010 9:14 AM by DarrylBurke RSS

    what is AWT component peer ?

    user575089
      I'm not in AWT.

      What is the difference between Component and Component Peer ?

      I'm aware of Component
      Component:
      http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Component.html


      However , What is Component Peer ? I don't get this. I need help here.

      I checked google but not convinced yet.
        • 1. Re: what is AWT component peer ?
          camickr
          A peer component is the OS specific equivalent component. AWT just exposes an API that allows you to set properties of that component. So when you create an AWT Button, you ultimately create a "button object" on the OS that you are using. The OS is responsible for painting the button and responding to events.
          • 2. Re: what is AWT component peer ?
            user575089
            camickr wrote:
            A peer component is the OS specific equivalent component. AWT just exposes an API that allows you to set properties of that component. So when you create an AWT Button, you ultimately create a "button object" on the OS that you are using. The OS is responsible for painting the button and responding to events.
            Thanks for the post. What I understand is here below..

            IF I write ,

            import java.awt.Button;
            ..................................

            Button button = new Button("My Button");

            It seems you are trying to say default button color changes in mac , windows and linux because OS is responsible for painting the button.

            You also said , +"A peer component is the *OS specific equivalent component*"+

            what is the OS specific equivalent component here in this button example ? Does it have a name ? what it is called ?

            Thanks for your time.
            • 3. Re: what is AWT component peer ?
              camickr
              It seems you are trying to say default button color changes in mac , windows and linux because OS is responsible for painting the button.
              Yes.
              what is the OS specific equivalent component here in this button example ? Does it have a name ? what it is called ?
              I don't know or care. I don't work at a low level so I don't know what the OS calls each object. That is why we use higher level programming languages so we don't have to worry about the details of how the OS works. Java especially works this way since its goal is to "write once run everywhere".
              • 4. Re: what is AWT component peer ?
                DarrylBurke
                Moderator action: Moved from New to Java

                db