Results 1 to 9 of 9
  1. #1
    aizen92 is offline Senior Member
    Join Date
    Nov 2010
    Posts
    155
    Rep Power
    5

    Default importing events

    Why when importing the java.awt or javax.swing and we want to use the event, why should we import the event alone, and not incuded when we import all of java.awt or javax.swing?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,762
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by aizen92 View Post
    Why when importing the java.awt or javax.swing and we want to use the event, why should we import the event alone, and not incuded when we import all of java.awt or javax.swing?
    If you import a sub-package x.y you are not importing the package x (nor vice versa); a.a.m.o.f. subpackages have nothing to do with their 'parent' packages.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I don't have a great understanding of the topic, but I found jos's statement confusing, here is my attempted explanation, which can be checked by looking at the arc. Others will also tell me if I am wrong.

    The javax.swing package called on import has a bunch of java source files and subdirectories. The import javax.swing.* imports all of the src files in that folder, but not it's subdirectories. javax.swing has a subdirectory called event.

    I hope this is correct. Others will call me out if I am giving bad information.

  4. #4
    aizen92 is offline Senior Member
    Join Date
    Nov 2010
    Posts
    155
    Rep Power
    5

    Default

    lol Jos sorry but i got somehow confused
    @sundae i got what you said, and if this is correct then i understood it

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You can confirm it by checking the src files which should be located in something like
    Java Code:
    c:/program files/java/jdk/src
    Go there and navigate your way to java.awt and see what files are in there and if there is an event sub directory in there.

  6. #6
    aizen92 is offline Senior Member
    Join Date
    Nov 2010
    Posts
    155
    Rep Power
    5

    Default

    actually yeh, it was true, i entered the src file, and in the javax there were the normal classes we use whem importing javax.swing.*, and there was a folder for event
    so i think sundae's explaination is true

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,762
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by sunde887 View Post
    I don't have a great understanding of the topic, but I found jos's statement confusing
    All I was saying is that if you import something from a sub-package x.y.* you are not importing anything from the package x.*; the same holds the other way around, i.e. if you import classes from x.* you are not importing anything from x.y.*; in other words, those two packages are completely unrelated when it comes to importing stuff from them.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Ah, yes, I understand you now.

  9. #9
    aizen92 is offline Senior Member
    Join Date
    Nov 2010
    Posts
    155
    Rep Power
    5

    Default

    same here, now i understand wat Jos means
    Thanks Jos, sundae

Similar Threads

  1. Listeners and events
    By cglacet in forum New To Java
    Replies: 3
    Last Post: 01-20-2011, 03:21 PM
  2. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 01:22 PM
  3. Need Help with events
    By Gatts79 in forum AWT / Swing
    Replies: 3
    Last Post: 09-23-2008, 04:18 AM
  4. swing events
    By chitra in forum AWT / Swing
    Replies: 3
    Last Post: 09-20-2008, 05:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •