-
Why? java.awt.AWTError: BoxLayout can't be shared
Below is my code. I got "java.awt.AWTError: BoxLayout can't be shared" error. But it's fine
if I replace the line 5 with
frame.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
Although I can pinpoint the location of error and fix it up, I don't know why this error happen.
public class BoxLayoutDemo {
public BoxLayoutDemo(){
JFrame frame = new JFrame("Button Demo");
Container pane = frame.getContentPane();
frame.setLayout(new BoxLayout(frame, BoxLayout.Y_AXIS));
JButton button1 = new JButton ("I Love You");
pane.add(button1);
frame.pack();
frame.setVisible(true);
}
public static void main (String[] args){
new BoxLayoutDemo();
}
}
-
a layout manager determines the size and position of the components within a container or panel, but has nothing to do with a JFrame
a JFrame is simply used as top-level window with a title and a border
Similar Threads
-
By Rob Teixeira in forum .NET
Replies: 129
Last Post: 06-06-2002, 05:23 AM
-
By Rob Teixeira in forum .NET
Replies: 15
Last Post: 05-31-2002, 03:30 PM
-
By Patrick Ireland in forum .NET
Replies: 5
Last Post: 05-10-2001, 06:19 PM
-
By Patrick Ireland in forum .NET
Replies: 3
Last Post: 05-07-2001, 03:04 PM
-
By Patrick Ireland in forum .NET
Replies: 0
Last Post: 04-26-2001, 10:01 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks