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);
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.