DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006
    Posts
    1

    Angry 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();
    }
    }

  2. #2
    Join Date
    Mar 2006
    Posts
    28
    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

  1. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 05:23 AM
  2. App Object
    By Rob Teixeira in forum .NET
    Replies: 15
    Last Post: 05-31-2002, 03:30 PM
  3. How To Do It - Shared Class Variables Part III
    By Patrick Ireland in forum .NET
    Replies: 5
    Last Post: 05-10-2001, 06:19 PM
  4. How To Do It - Shared Class Variables Part IV
    By Patrick Ireland in forum .NET
    Replies: 3
    Last Post: 05-07-2001, 03:04 PM
  5. Replies: 0
    Last Post: 04-26-2001, 10:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links