Results 1 to 2 of 2
- 03-18-2012, 10:24 AM #1Member
- Join Date
- Mar 2012
- Rep Power
How to change the location of buttons on a JFrame???
By executing the below code,Im getting the 4 buttons(side by side) in the top-center position.
But,I want to change the positions of the button to the complete left side of my frame...i,e; one below the other...How to change it...Pls help me out...Thanks ...:)
JFrame frame = new JFrame("FIRST OUTLAY ");
JPanel pan = new JPanel();
button1 = new JButton("OS info");
button2 = new JButton("N/W info");
button3 = new JButton("Java info");
button4 = new JButton("Memory info");
area = new JTextArea();
jsp= new JScrollPane(area);
jsp.setBounds(100, 60, 380, 400);
- 03-18-2012, 11:57 AM #2
Re: How to change the location of buttons on a JFrame???
Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)
1) Look around the FAQs section of the site and learn how to post code so it retains its formatting.
2) Don't use setBounds(...), use an appropriate layout manager. In your code sample, setBounds(...) wouldn't be effective, and you wouldn't see the scroll pane either.
3) As far as your immediate question is concerned, FlowLayout has more than one constructor. Apply the one most appropriate to your need.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- By michalss in forum AWT / SwingReplies: 6Last Post: 04-21-2011, 12:33 PM
- By Jodokus in forum AWT / SwingReplies: 5Last Post: 01-20-2011, 05:10 PM
- By jchsu in forum AWT / SwingReplies: 3Last Post: 02-25-2010, 11:06 AM
- By petrosgraf in forum Threads and SynchronizationReplies: 5Last Post: 04-18-2009, 02:24 AM
- By sayan751 in forum JDBCReplies: 3Last Post: 03-19-2009, 02:42 PM