maygapixel

Untitled

Apr 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // GuiComponents.java
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. class GuiComponents extends JFrame{
  6.       private JButton jbbutton;
  7.       private JCheckBox jcbcheck1;
  8.       private JLabel jllabel;
  9.       private JCheckBox jcbcheck2;
  10.       private JTextField jtftext;
  11.       private JTextArea jtatext;
  12.       private JComboBox jcbchoice;
  13.       private JList jllist;
  14.       private JRadioButton jrbcheck1,jrbcheck2,jrbcheck3;
  15.       private JPanel p1,p2;
  16.       private JScrollPane jspane;
  17.       private String[] combo  = {"Yes","No"};
  18.       public GuiComponents(){
  19.       p1 = new JPanel(new FlowLayout());
  20.       p2 = new JPanel(new FlowLayout());
  21.       jbbutton = new JButton("Button");
  22.       jcbcheck1 = new JCheckBox();
  23.       jllabel = new JLabel("Label");
  24.       jcbcheck2 = new JCheckBox();
  25.       jtftext = new JTextField("Text Field");
  26.       jtatext = new JTextArea("Text Area",5,15);
  27.      
  28.       String[] mylist = {"item1","item2","item3","item4","item5","item6","item7","item8","item9","item10"};
  29.       jllist = new JList(mylist);
  30.       jspane = new JScrollPane(jllist);
  31.      
  32.       jcbchoice = new JComboBox(combo);
  33.       jrbcheck1 = new JRadioButton("often");
  34.       jrbcheck2 = new JRadioButton("sometime");
  35.       jrbcheck3 = new JRadioButton("never");
  36.       p1.add(jbbutton);
  37.       p1.add(jcbcheck1);
  38.       p1.add(jllabel);
  39.       p1.add(jcbcheck2);
  40.       p1.add(jtftext);
  41.       p1.add(jtatext);
  42.       p2.add(jspane);
  43.       p2.add(jcbchoice);
  44.       p2.add(jrbcheck1);
  45.       p2.add(jrbcheck2);
  46.       p2.add(jrbcheck3);
  47.       ButtonGroup group = new ButtonGroup();
  48.       group.add(jrbcheck1);
  49.       group.add(jrbcheck2);
  50.       group.add(jrbcheck3);
  51.      
  52.      
  53.       Container c = getContentPane();
  54.       c.setLayout(new BorderLayout());
  55.       c.add(p1,BorderLayout.NORTH);
  56.       c.add(p2,BorderLayout.CENTER);
  57.       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  58.       setSize(450,300);
  59.       setTitle("GuiComponents");
  60.       setVisible(true);
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment