Guest User

Untitled

a guest
Nov 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import sun.net.idn.StringPrep;
  2.  
  3. import javax.swing.*;
  4. import java.awt.*;
  5.  
  6. /**
  7. * ReviewQuestion17_10.java
  8. * Steven Elliott, Jr.
  9. * CMIS242 Week 5 Conference
  10. * java version "1.6.0_33"
  11. * Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
  12. * Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
  13. * <p/>
  14. * Purpose:
  15. * Create a combobox, add three items to it, and retrieve a
  16. * selected item.
  17. */
  18. public class ReviewQuestion17_10 extends JFrame {
  19.  
  20. // Create an array of items
  21. String[] itemArray = {"Item", "Item2", "Item3"};
  22.  
  23.  
  24. ReviewQuestion17_10() {
  25. // Create a simple GridLayout
  26. JPanel panel = new JPanel(new GridLayout(1,1));
  27. panel.add(new JLabel("Demonstrating Combobox"));
  28. final JComboBox itemBox;
  29. itemBox = new JComboBox(itemArray);
  30. panel.add(itemBox);
  31.  
  32. add(panel, BorderLayout.PAGE_START);
  33.  
  34. }
  35.  
  36. public static void main(String[] args) {
  37. ReviewQuestion17_10 reviewQuestion17_10 = new ReviewQuestion17_10();
  38. reviewQuestion17_10.pack();
  39. reviewQuestion17_10.setVisible(true);
  40. reviewQuestion17_10.setTitle("Combobox Demo");
  41. reviewQuestion17_10.setLocationRelativeTo(null);
  42. reviewQuestion17_10.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  43. }
  44.  
  45. }
Add Comment
Please, Sign In to add comment