• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BorderLayout error

 
Ian Cockcroft
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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};
 
Ian Cockcroft
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, it works fine now.Feel a bit silly. :roll:
I have added the event handler...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic