wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Simple GUI question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Simple GUI question" Watch "Simple GUI question" New topic
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: 18541
    
    8

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: 5233
    
  12

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: 2265
    
    3

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple GUI question