/* * CategoryPanel.java * */ package myamazonclient; import java.util.Vector; public class CategoryPanel extends javax.swing.JPanel { /** Creates new form CategoryPanel */ public CategoryPanel() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents selectCategoryLable = new javax.swing.JLabel(); booksComboBox = new javax.swing.JComboBox(); setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 20, 60)); setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true)); selectCategoryLable.setText("Select Book Category"); add(selectCategoryLable); booksComboBox.setModel(new javax.swing.DefaultComboBoxModel(getListOfBooks())); booksComboBox.setSelectedIndex(0); this.selectedBookname = (String) booksComboBox.getSelectedItem(); booksComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { booksComboBoxActionPerformed(evt); } }); add(booksComboBox); }//GEN-END:initComponents private void booksComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_booksComboBoxActionPerformed // Add your handling code here: this.selectedBook = booksComboBox.getSelectedIndex(); this.selectedBookname = (String) booksComboBox.getSelectedItem(); AmazonServices.bookName = this.selectedBookname; }//GEN-LAST:event_booksComboBoxActionPerformed public Vector getListOfBooks() { Vector v; v = new AmazonProxy().getBookTypes(); return v; } public String getSelectedBookName() { return this.selectedBookname; } private int selectedBook; private String selectedBookname; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox booksComboBox; private javax.swing.JLabel selectCategoryLable; // End of variables declaration//GEN-END:variables }