votako

Bikeshop

Jun 17th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. package bibikes;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7. import javax.swing.*;
  8.  
  9. public class Bike implements ActionListener {
  10.     String[] bikeName = new String[]{   "B.O.N.E", "Colony", "DK", "Fit", "Ghost"   };
  11.    
  12.     Integer[] numberOfBike = new Integer[]{ 1, 2,3, 4, 5    };
  13.    
  14.     JComboBox comboxName = new JComboBox(bikeName);
  15.     JComboBox comboxNumber = new JComboBox(numberOfBike);
  16.    
  17.     JLabel welcome = new JLabel("welcome to my bike magazine");
  18.    
  19.     JButton ok = new JButton("ok");
  20.    
  21.     JPanel panel = new JPanel();
  22.    
  23.     public void init(){
  24.         GridLayout bl = new GridLayout(4,1);
  25.         panel.setLayout(bl);
  26.         panel.add(welcome);
  27.         panel.add(comboxName);
  28.         panel.add(comboxNumber);
  29.         panel.add(ok);
  30.        
  31.         JFrame frame = new JFrame("Bike shop");
  32.         frame.setContentPane(panel);
  33.  
  34.         frame.pack();
  35.  
  36.         frame.setVisible(true);
  37.        
  38.         ok.addActionListener(this);
  39.     }
  40.    
  41.     public void actionPerformed(ActionEvent e) {
  42.         String BN = (String) comboxName.getSelectedItem();
  43.         Integer NB = (Integer) comboxNumber.getSelectedItem();
  44.         JOptionPane.showConfirmDialog(null,
  45.                 "you chose " + BN+" "+ NB + " pieces",
  46.                 null, JOptionPane.PLAIN_MESSAGE);
  47.        
  48.     }
  49.    
  50.    
  51.    
  52.     public static void main(String[] args) {
  53.         Bike b = new Bike();
  54.         b.init();
  55.  
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment