| Author |
Simple GUI question
|
Matt Pavlovich
Ranch Hand
Joined: Aug 14, 2010
Posts: 98
|
|
Hello everyone.
I apologize the simplicity of this question, but this is my first time really working with GUI's. My test instructions state something to the effect that I must build my GUI from components from the Java Foundation Classes (Swing components). However, in my studies I am seeing an import for java.awt in addition to .swing. So, is .awt considered to be a Swing component? Can I use it? I notice the SCJD book imports both, but seeing as how it is now a few years old, I thought I should ask.
Thanks to everyone.
Matt
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
Let me put it this way... String isn't a Swing component. Would you conclude that you couldn't use String in your program?
Of course you wouldn't. That would be absurd. Of course you can use classes which support your use of those Swing components. For example you might need to use a Font object. A java.awt.Font object, to be specific.
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4349
|
|
You are not supposed to use an awt component if a swing version exists. For example: you have java.awt.TextField and javax.swing.JTextField, so you should use the JTextField. But if you have a look at the class hierarchy you'll see it extends java.awt.Component. And the layout managers are all in the awt-package, so your gui classes certainly will have imports from the awt-package.
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
|
It is also allowed to have an ActionListener in a button. Its fully qualified name is java.awt.event.ActionListener.
|
Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
|
 |
Matt Pavlovich
Ranch Hand
Joined: Aug 14, 2010
Posts: 98
|
|
Very helpful. Thank you, guys.
|
 |
 |
|
|
subject: Simple GUI question
|
|
|