-
1 Attachment(s)
java window
What's the matter with this code?
I want to get something like on the attached picture :S
Code:
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class Bounce {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(new Dimension(600, 350));
frame.setResizable(false);
frame.setTitle(new String("test"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(600, 300));
panel.setLayout(new GridLayout(0,2,50,50));
JTextArea text1 = new JTextArea();
JTextArea text2 = new JTextArea();
panel.add(text1);
panel.add(text2);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
}
-
You tell us. What does the code do instead?
-
And what's the problem? It works fine for me.
-
It stretches text fields on whole window when I want it to make an alignment of 50 pixels :S