Results 1 to 3 of 3
  1. #1
    Huskies's Avatar
    Huskies is offline Member
    Join Date
    Jul 2011
    Posts
    47
    Rep Power
    0

    Post Question about Packages

    Hey guys,

    I know that there is no formal sub-package in java (at least to the best of my knowledge). If I understand correctly, then "com.package1" is entirely separate and different than "com.package1.alpha".

    My question is this: How do you get imports such as "javax.swing.*" without doing specifics such as "javax.swing.JFrame"?
    How are they able to nest these packages?

    I'm sure I am confused as to what is actually happening, so if you could inform me that would be great.

    Thank you in advance!
    -Huskies

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,858
    Rep Power
    8

    Default Re: Question about Packages

    That's not nesting packages- that's simply importing every class in a package. JFrame is not a package, it's a class.

    For example, you couldn't just do this: import javax.*; and then use JFrame.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    asifzbaig is offline Member
    Join Date
    May 2011
    Posts
    56
    Rep Power
    0

    Default Re: Question about Packages

    How do you get imports such as "javax.swing.*" without doing specifics such as "javax.swing.JFrame"?
    Actually, "javax.swing.*" and "javax.swing.JFrame" are two different things.

    If your using "*" in impoting it means your are importing all the classes in the package "javax.swing".
    Note that it only import on classes in the package rather than sub-package.
    For Example if you want to import classes under sub-package of javax.swing you have to declare it as : "javax.swing.event.*;".

    But, in case of writing "javax.swing.JFrame;" imports only JFrame class of javax.swing package.

    For more information refer : Package Tutorial

Similar Threads

  1. Beginner Question About Packages, etc
    By Humphrey Bogart in forum New To Java
    Replies: 15
    Last Post: 03-24-2011, 04:45 PM
  2. Question about packages.
    By dragonchr15 in forum New To Java
    Replies: 7
    Last Post: 08-07-2009, 11:34 PM
  3. packages
    By fogus in forum New To Java
    Replies: 1
    Last Post: 03-24-2009, 06:14 AM
  4. Replies: 3
    Last Post: 02-12-2008, 11:03 AM

Posting Permissions

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