Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bibikes;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- public class Bike implements ActionListener {
- String[] bikeName = new String[]{ "B.O.N.E", "Colony", "DK", "Fit", "Ghost" };
- Integer[] numberOfBike = new Integer[]{ 1, 2,3, 4, 5 };
- JComboBox comboxName = new JComboBox(bikeName);
- JComboBox comboxNumber = new JComboBox(numberOfBike);
- JLabel welcome = new JLabel("welcome to my bike magazine");
- JButton ok = new JButton("ok");
- JPanel panel = new JPanel();
- public void init(){
- GridLayout bl = new GridLayout(4,1);
- panel.setLayout(bl);
- panel.add(welcome);
- panel.add(comboxName);
- panel.add(comboxNumber);
- panel.add(ok);
- JFrame frame = new JFrame("Bike shop");
- frame.setContentPane(panel);
- frame.pack();
- frame.setVisible(true);
- ok.addActionListener(this);
- }
- public void actionPerformed(ActionEvent e) {
- String BN = (String) comboxName.getSelectedItem();
- Integer NB = (Integer) comboxNumber.getSelectedItem();
- JOptionPane.showConfirmDialog(null,
- "you chose " + BN+" "+ NB + " pieces",
- null, JOptionPane.PLAIN_MESSAGE);
- }
- public static void main(String[] args) {
- Bike b = new Bike();
- b.init();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment