LuDaCriS66
Platinum Member
Sorry but I've been working on this work all day and I'm 95% done but I just can't get my GUI looking right. That's all I need to do.. is to get the button on the right spot.
Basically, I need my GUI to look like this
But instead, it looks like this with the button to the right
But this is my code here and it's not coming out right.
The calculate button is acting like it's in the same object as the text fields. Any ideas?
initialAmountLabel = new JLabel("Initial investment amount", LEFT);
initialAmountField = new InputJTextField("", 10);
interestRateLabel = new JLabel("Annual interest rate in %", LEFT);
interestRateField = new InputJTextField("", 5);
output = new JTextArea(20,60); // 10 rows and 20 columns
output.setEditable(false);
output.setFont(new Font("Courier", Font.PLAIN, 11));
JPanel p = new JPanel(new GridLayout(2,2));
p.add(initialAmountLabel);
p.add(initialAmountField);
p.add(interestRateLabel);
p.add(interestRateField);
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(p);
cp.add(calculate);
cp.add(new JScrollPane(output));
If I make the calc button and the TextArea the same object, the calc button is the same size as the TextArea....
any help is appreciated
Basically, I need my GUI to look like this
But instead, it looks like this with the button to the right
But this is my code here and it's not coming out right.
The calculate button is acting like it's in the same object as the text fields. Any ideas?
initialAmountLabel = new JLabel("Initial investment amount", LEFT);
initialAmountField = new InputJTextField("", 10);
interestRateLabel = new JLabel("Annual interest rate in %", LEFT);
interestRateField = new InputJTextField("", 5);
output = new JTextArea(20,60); // 10 rows and 20 columns
output.setEditable(false);
output.setFont(new Font("Courier", Font.PLAIN, 11));
JPanel p = new JPanel(new GridLayout(2,2));
p.add(initialAmountLabel);
p.add(initialAmountField);
p.add(interestRateLabel);
p.add(interestRateField);
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(p);
cp.add(calculate);
cp.add(new JScrollPane(output));
If I make the calc button and the TextArea the same object, the calc button is the same size as the TextArea....
any help is appreciated