What's the difference between "import.javax.swing*" and JFrame inheritance
Is it possible to use all the components of Swing class such as JFrame without extending an existing class to JFrame? if so why then programmers usually extend their classes to JFrame class and import swing at the same time?
Re: What's the difference between "import.javax.swing*" and JFrame inheritance
JFrame is one class in the javax.swing package.
Extending a class has nothing to do with what import statements you code.
An import statement is used by the compiler to find the definition of a class that is defined in a package.
Re: What's the difference between "import.javax.swing*" and JFrame inheritance
Well, can I use JFrame simply by importing all of the swing classes without extending an existing class to JFrame? I am sorry if my question doesn't make sense but I am a newbie in java programming and in a tutorial few days back I saw someone making a JFrame only by importing all of the swing classes and he didn't extend the existing class to JFrame.
Re: What's the difference between "import.javax.swing*" and JFrame inheritance
Quote:
Originally Posted by
Johnny Bravo
... making a JFrame only by importing all of the swing classes and he didn't extend the existing class to JFrame.
If you do that then this would fail:
Code java:
public JFrame jf = new ClassThatDoesNotExtendJFrame();//fail
Re: What's the difference between "import.javax.swing*" and JFrame inheritance
You do not need to use the import statement to use any of the java classes. You can code the full package/class name:
Code :
public MyFrame extends javax.swing.JFrame { ...}
The import statement tells the compiler where to look to find class definitions. It's sort of an extension of classpath. The import statement does not create any code in a program.
Re: What's the difference between "import.javax.swing*" and JFrame inheritance
using import statements is just a shortcut. At any time you can use fully qualified name of classes or interfaces.