package ernya;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.DataInputStream;
import java.net.URL;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.dyno.visual.swing.layouts.Bilateral;
import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;
public class Applet extends JApplet {
private static final long serialVersionUID = 1L;
private JTextField jTextField0;
private JList jList0;
private JScrollPane jScrollPane0;
private JSeparator jSeparator0;
private JList jList1;
private JScrollPane jScrollPane1;
private JLabel jLabel0;
private JLabel jLabel1;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
private JCheckBox jCheckBox0;
private JList jList2;
private JScrollPane jScrollPane2;
private JButton jButton0;
private JButton jButton1;
private JPicturePanel jPicturePanel0;
private JPicturePanel jPicturePanel1;
private JTextArea jTextArea0;
private JScrollPane jScrollPane3;
DefaultListModel cartList = new DefaultListModel();
DefaultListModel colorList = new DefaultListModel();
DefaultListModel itemList = new DefaultListModel();
final String store = "Store Price: ";
final String myBuy = "My Buy Price: ";
final String mySale = "My Sale Price: ";
final String stock = "Current Stock: ";
final String total = "Total: ";
public ArrayList<String> items;
public ArrayList<Integer> price;
public ArrayList<String[]> color;
@SuppressWarnings("deprecation")
public void init() {
try {
URL itemUrl = new URL(
"http://etopsirhc.110mb.com/Java/Applets/Resources/TCC/items.txt");
DataInputStream itemIn = new DataInputStream(itemUrl.openStream());
try {
String in = itemIn.readLine();
while (in != null) {
String[] content = in.split("~");
items.add(content[0]); // this is where i get a null pointer exception as
price.add(Integer.parseInt(content[1])); // well as the the 2 ".add" things below
String[] colors = content[2].split(":"); // it . i also tried having this in a separate
color.add(colors); // class , but i still got it , any idea whats wrong ?
System.out.println(in);
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
initComponents();
}
private void initComponents() {
setLayout(new GroupLayout());
add(getJTextField0(), new Constraints(new Leading(12, 192, 10, 10),
new Leading(12, 12, 12)));
add(getJSeparator0(), new Constraints(new Bilateral(12, 12, 376),
new Leading(265, 10, 12, 12)));
add(getJScrollPane1(), new Constraints(new Bilateral(209, 12, 22),
new Leading(11, 120, 10, 10)));
add(getJLabel0(), new Constraints(new Bilateral(209, 13, 41),
new Leading(143, 12, 12)));
add(getJLabel1(), new Constraints(new Bilateral(209, 13, 41),
new Leading(165, 12, 12)));
add(getJLabel2(), new Constraints(new Bilateral(209, 13, 41),
new Leading(187, 12, 12)));
add(getJLabel3(), new Constraints(new Bilateral(209, 13, 41),
new Leading(209, 12, 12)));
add(getJLabel4(), new Constraints(new Bilateral(209, 13, 41),
new Leading(231, 12, 12)));
add(getJScrollPane0(), new Constraints(new Leading(13, 190, 12, 12),
new Leading(39, 220, 12, 12)));
add(getJScrollPane2(), new Constraints(new Leading(12, 192, 108, 108),
new Bilateral(278, 12, 22)));
add(getJButton0(), new Constraints(new Leading(216, 170, 12, 12),
new Leading(277, 12, 12)));
add(getJButton1(), new Constraints(new Leading(216, 170, 12, 12),
new Leading(309, 12, 12)));
add(getJCheckBox0(), new Constraints(new Leading(216, 170, 8, 8),
new Leading(343, 8, 8)));
//add(getJPicturePanel0(), new Constraints(new Leading(228, 55, 12, 12),
// new Leading(369, 55, 12, 12)));
//add(getJPicturePanel1(), new Constraints(new Leading(317, 55, 10, 10),
// new Leading(369, 55, 12, 12)));
add(getJScrollPane3(), new Constraints(new Leading(215, 172, 12, 12),
new Bilateral(431, 12, 22)));
setSize(400, 541);
}
private JScrollPane getJScrollPane3() {
if (jScrollPane3 == null) {
jScrollPane3 = new JScrollPane();
jScrollPane3.setViewportView(getJTextArea0());
}
return jScrollPane3;
}
private JTextArea getJTextArea0() {
if (jTextArea0 == null) {
jTextArea0 = new JTextArea();
jTextArea0.setText("jTextArea0");
jTextArea0.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
jTextArea0MouseMouseReleased(event);
}
});
}
return jTextArea0;
}
// private JPicturePanel getJPicturePanel1() {
// if (jPicturePanel1 == null) {
// jPicturePanel1 = new JPicturePanel();
// jPicturePanel1.setBorder(BorderFactory.createEtchedBorder(
// EtchedBorder.LOWERED, null, null));
// }
// return jPicturePanel1;
// }
//
// private JPicturePanel getJPicturePanel0() {
// if (jPicturePanel0 == null) {
// jPicturePanel0 = new JPicturePanel();
// jPicturePanel0.setBorder(BorderFactory.createEtchedBorder(
// EtchedBorder.LOWERED, null, null));
// }
// return jPicturePanel0;
// }
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("Remove From Cart");
jButton1.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
jButton1MouseMouseReleased(event);
}
});
}
return jButton1;
}
private JButton getJButton0() {
if (jButton0 == null) {
jButton0 = new JButton();
jButton0.setText("Add To Cart");
jButton0.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
jButton0MouseMouseReleased(event);
}
});
}
return jButton0;
}
private JScrollPane getJScrollPane2() {
if (jScrollPane2 == null) {
jScrollPane2 = new JScrollPane();
jScrollPane2.setViewportView(getJList2());
}
return jScrollPane2;
}
private JList getJList2() {
if (jList2 == null) {
jList2 = new JList();
jList2.setModel(cartList);
jList2.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
jList2ListSelectionValueChanged(event);
}
});
}
return jList2;
}
private JCheckBox getJCheckBox0() {
if (jCheckBox0 == null) {
jCheckBox0 = new JCheckBox();
jCheckBox0.setText("Check For Sale Setup");
}
return jCheckBox0;
}
private JLabel getJLabel4() {
if (jLabel4 == null) {
jLabel4 = new JLabel();
jLabel4.setText(total);
}
return jLabel4;
}
private JLabel getJLabel3() {
if (jLabel3 == null) {
jLabel3 = new JLabel();
jLabel3.setText(stock);
}
return jLabel3;
}
private JLabel getJLabel2() {
if (jLabel2 == null) {
jLabel2 = new JLabel();
jLabel2.setText(myBuy);
}
return jLabel2;
}
private JLabel getJLabel1() {
if (jLabel1 == null) {
jLabel1 = new JLabel();
jLabel1.setText(mySale);
}
return jLabel1;
}
private JLabel getJLabel0() {
if (jLabel0 == null) {
jLabel0 = new JLabel();
jLabel0.setText(store);
}
return jLabel0;
}
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setViewportView(getJList1());
}
return jScrollPane1;
}
private JList getJList1() {
if (jList1 == null) {
jList1 = new JList();
jList1.setModel(colorList);
jList1.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
jList1ListSelectionValueChanged(event);
}
});
}
return jList1;
}
private JSeparator getJSeparator0() {
if (jSeparator0 == null) {
jSeparator0 = new JSeparator();
}
return jSeparator0;
}
private JScrollPane getJScrollPane0() {
if (jScrollPane0 == null) {
jScrollPane0 = new JScrollPane();
jScrollPane0.setViewportView(getJList0());
}
return jScrollPane0;
}
private JList getJList0() {
if (jList0 == null) {
jList0 = new JList();
jList0.setModel(itemList);
jList0.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
jList0ListSelectionValueChanged(event);
}
});
}
return jList0;
}
private JTextField getJTextField0() {
if (jTextField0 == null) {
jTextField0 = new JTextField();
jTextField0.setText("jTextField0");
jTextField0.addInputMethodListener(new InputMethodListener() {
public void caretPositionChanged(InputMethodEvent event) {
jTextField0InputMethodCaretPositionChanged(event);
}
public void inputMethodTextChanged(InputMethodEvent event) {
jTextField0InputMethodInputMethodTextChanged(event);
}
});
}
return jTextField0;
}
public Applet() {
initComponents();
}
private void jTextField0InputMethodCaretPositionChanged(
InputMethodEvent event) {
}
private void jTextField0InputMethodInputMethodTextChanged(
InputMethodEvent event) {
}
private void jList0ListSelectionValueChanged(ListSelectionEvent event) {
}
private void jList1ListSelectionValueChanged(ListSelectionEvent event) {
}
private void jList2ListSelectionValueChanged(ListSelectionEvent event) {
}
private void jButton1MouseMouseReleased(MouseEvent event) {
}
private void jButton0MouseMouseReleased(MouseEvent event) {
}
private void jTextArea0MouseMouseReleased(MouseEvent event) {
}
}