does this compile on your machine?
I have this simple code with what I think is no flaws, but yet it won't compile. I think it's just my compiler being gay again, but I wanted to see if you guys could compile it.
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CurrencyConverter extends JApplet implements ActionListener
{
JComboBox cbFrom;
JTextField txtAmount;
JList list;
String[] strCurrency = {"US Dollar", "Canadian Dollar", "Mexican Pesos", "Australain Dollar"};
public void init()
{
Container pane = getContentPane();
pane.setLayout(new FlowLayout());
JPanel row1 = new JPanel();
JLabel lblAmount = new JLabel();
txtAmount = new JTextField(10);
row1.add(lblAmount);
row1.add(txtAmount);
JPanel row2 = new JPanel();
JLabel lblFrom = new JLabel("From");
cbFrom = new JComboBox();
cbFrom.add(strCurrency);
row2.add(lblFrom);
row2.add(cbFrom);
JPanel row3 = new JPanel();
list = new JList("---------Results---------");
row3.add(list);
pane.add(row1);
pane.add(row2);
pane.add(row3);
setVisible(true);
setContentPane(pane);
}
public void actionPerformed(ActionEvent ae)
{
}
}
<Moderator added green checkmark in the first thread>
Re: does this compile on your machine?
JList's constructor dosen't take a String. Also JCombo box doesn't had a add() method and also one that take a String[]. You would have to use addItem(Object anObject).
Re: does this compile on your machine?
I changed it to a textarea. I don't know why I was using a list at that point. The problem was with the combobox. It said it didn't recognize the add method, which I looked around on the internet and the source code I saw used it. For some reason I had to change it to addItem() instead of add();