Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- class GuiComponents extends JFrame{
- private JLabel label;
- private JComboBox choice;
- private Icon icons[];
- private int count =1;
- private String[] combo = {"Yes","No"};
- public GuiComponents(){
- Container c = getContentPane();
- c.setLayout(new FlowLayout());
- JButton jb = new JButton("Button");
- c.add(jb);
- JCheckBox jcb1 = new JCheckBox();
- Jlabel jl = new JLabel("Label");
- JCheckBox jcb2 = new JCheckBox();
- JTextField jtf = new JTextField("TextField");
- JTextArea jta = new JTextArea("TextArea",5,20);
- c.add(jcb1);
- c.add(jl);
- c.add(jcb2);
- c.add(jtf);
- c.add(jta);
- //ScrollPane
- JScrollPane scroll = new JScrollPane();
- Scroll.setBounds(100,52,130,50);
- // list
- final String[] items = {"item 1","item 2","item 3","item 4","item 5","item 6","item 7","item 8","item 9","item 10",};
- final JList list = new JList(items);
- list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- Scroll.setViewportView(list);
- getContentPane().add(scroll);
- // JComboBox
- icons = new Icon[combo.length];
- choice = new JComboBox(combo);
- JRadioButton often = new JRadioButton("often", true);
- c.add(often);
- JRadioButton sometimes = new JRadioButton("sometimes ", false);
- c.add(sometimes);
- JRadioButton never = new JRadioButton("never ", false);
- c.add(never);
- //Setup
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setSize(500,300);
- setTitle("GuiComponents");
- setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement