-
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
-
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
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