Advertisement
maygapixel

Untitled

Apr 22nd, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. class GuiComponents extends JFrame{
  5.          
  6. private JLabel label;
  7. private JComboBox choice;
  8. private Icon icons[];
  9. private int count =1;
  10. private String[] combo  = {"Yes","No"};
  11. public GuiComponents(){
  12. Container c = getContentPane();      
  13. c.setLayout(new FlowLayout());
  14. JButton jb = new JButton("Button");
  15. c.add(jb);
  16. JCheckBox jcb1 = new JCheckBox();
  17. Jlabel jl = new JLabel("Label");
  18. JCheckBox jcb2 = new JCheckBox();
  19. JTextField jtf = new JTextField("TextField");
  20. JTextArea jta = new JTextArea("TextArea",5,20);
  21. c.add(jcb1);
  22. c.add(jl);
  23. c.add(jcb2);
  24. c.add(jtf);
  25. c.add(jta);
  26. //ScrollPane
  27. JScrollPane scroll = new JScrollPane();
  28. Scroll.setBounds(100,52,130,50);
  29. // list
  30. final String[] items = {"item 1","item 2","item 3","item 4","item 5","item 6","item 7","item 8","item 9","item 10",};
  31. final JList list = new JList(items);
  32. list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
  33. Scroll.setViewportView(list);
  34. getContentPane().add(scroll);
  35. // JComboBox
  36. icons = new Icon[combo.length];
  37. choice = new JComboBox(combo);
  38. JRadioButton often = new JRadioButton("often", true);
  39. c.add(often);
  40. JRadioButton sometimes = new JRadioButton("sometimes ", false);
  41. c.add(sometimes);
  42. JRadioButton never = new JRadioButton("never ", false);
  43. c.add(never);
  44. //Setup
  45. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  46. setSize(500,300);
  47. setTitle("GuiComponents");
  48. setVisible(true);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement