Why? java.awt.AWTError: BoxLayout can't be shared


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Why? java.awt.AWTError: BoxLayout can't be shared

  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

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center