import java.applet.*; import java.awt.*; import javax.swing.*; import java.util.*; import isip.java.bullyse.bullydb.*; public class TransactionApplet extends JApplet { public static BullyDB db; public void init() { // setup the BullyDB object; // db = new BullyDB(); // get the user name // String user = getUser(); // get the list of stocks they have invested in // Vector symbols = getSymbols(user); // layout the panel and draw it for all the stocks owned // layoutPanel(symbols); } private Vector getSymbols(String user) { // at this point, the database should be queried for // all of the stocks that this user owns // Vector full = db.getHoldings(user); full.remove(0); Vector returnVector = new Vector(5,5); returnVector.add("Cash"); for(int i = 0; i < full.size(); i++) { String sym = ((Vector)full.elementAt(i)).elementAt(0).toString(); returnVector.add(sym); } return returnVector; } private String getUser() { // somehow the username needs to be passed into // the applet // return "000001"; } private void layoutPanel(Vector symbols) { // set the layout so that all of the transactions will be spaced // evenly in a single column. There is a horizontal and vertical // gap of three pixels. // JPanel transactionPanel = new JPanel(); transactionPanel.setLayout(new GridLayout(symbols.size(), 1, 3, 3)); transactionPanel.setSize(new Dimension(25 * symbols.size(), 400)); // set the background color to the Gray in the webpage // transactionPanel.setBackground(new Color(0xd0, 0xd0, 0xd0)); System.out.println(symbols.size()); for(int i=0; i < symbols.size(); i++) { // create the transactions and add them to the applet // Transaction tempTransaction = new Transaction((String)symbols.get(i), this, getUser()); transactionPanel.add(tempTransaction); } JScrollPane scrollPane = new JScrollPane(transactionPanel); scrollPane.setPreferredSize(new Dimension(300, 72)); System.out.println(scrollPane.getVerticalScrollBar().getBlockIncrement()); // scrollPane.getVerticalScrollBar().setBlockIncrement(100); this.getContentPane().add(scrollPane); } }