GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes BorderLayout error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "BorderLayout error" Watch "BorderLayout error" New topic
Author

BorderLayout error

Ian Cockcroft
Greenhorn

Joined: Feb 17, 2002
Posts: 29
Hi all,
I have put this code into my compiler, it is straight out of a book, exact, word for word and even the API specs say its right, but I get an error.
Does anyone know whats wrong?

The error i'm getting is
SwingUI.java:31: cannot resolve symbol
symbol : class BorderLayout
location: class SwingUI
panel.setLayout(new BorderLayout
(1,1));
There might be some unclosed string error cause this editor is to small.
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
I don't happen to have a compiler handy, so please tell me if I'm wrong......
I think the problem is with the following import statement:
import java.awt.BorderLayout.*;
This statement essentially tries to import all class files in the package java.awt.BorderLayout. However, BorderLayout is a class that belongs to the package java.awt. Therefore, the import statement as you've listed it does not import the BorderLayout class. Rather, it tries to import all classes of a fictitous package java.awt.BorderLayout.
Try changing your import statement to:
import java.awt.BorderLayout;
[ April 11, 2002: Message edited by: Dave Winn ]

Fun programming etcetera!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well, if you fully qualify the classes it will work.
Or you can change your imports to actually import those classes (get rid of the .*)
import java.awt.Color;
import java.awt.BorderLayout;
Or you can just change your import to
import java.awt.*;
//import java.awt.Color.*;
//import java.awt.BorderLayout.*;

PS: you will need to add:
public void actionPerformed(ActionEvent e){//fun stuff};


"JavaRanch, where the deer and the Certified play" - David O'Meara
Ian Cockcroft
Greenhorn

Joined: Feb 17, 2002
Posts: 29
Thanks guys, it works fine now.Feel a bit silly. :roll:
I have added the event handler...
 
GeeCON Prague 2014
 
subject: BorderLayout error