DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    59

    Adding buttons to Frame

    Ive a question, how can i add 3 JButton's to a frame?


    example:
    [code]

    public BlasterFrame(String title) {
    super (title, true, true, true, true);

    JButton jb = new JButton("ok");
    Container c = getContentPane();
    //c.add(jb);

    c.add(jt, BorderLayout.CENTER);
    c.add(img1, BorderLayout.WEST);

    ButtonGroup bg = new ButtonGroup();
    c.add(jbNext, BorderLayout.SOUTH);
    // c.add(jbPrevious, BorderLayout.SOUTH);
    // c.add(jbClose, BorderLayout.SOUTH);

    setSize(200,300);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    }




    thank you
    My own java video tutorials, feel free to watch it.
    http://www.engineeringserver.com/for...amming-b311.0/ Need java help? For beginning and intermediate java coders!

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    You do that by adding a JPanel to the frames contentPane, say ctrlPanel, then
    you set that panels Layoutmanager to something suitable (FlowLayout, GridLayout...)
    and add your buttons to that panel, big deal

    Note: JPanels and JButtons are all Components, but the JPanels are also
    Containers. As "addable objects" they are all Components.
    Last edited by sjalle; 06-19-2005 at 08:55 AM.
    eschew obfuscation

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