package org.example; import javax.swing.*; import java.awt.*; public class GUI extends JFrame { // Jednotlivé prvky JPanel innerPanel; JLabel text1, text2; JButton button1; JComboBox box; JCheckBox checkBox1, checkBox2; JRadioButton radio1, radio2; ButtonGroup group; JMenuBar bar; JMenu menu, item2; JMenuItem item1, item3, item4, item2a, item2b; JTextField textfield; JSlider slider; JList list; DefaultListModel listModel; public GUI(String title) throws HeadlessException { super(title); setSize(new Dimension(500,500)); setLocationRelativeTo(null); innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel,BoxLayout.PAGE_AXIS)); text1 = new JLabel("Text 1"); text2 = new JLabel("Text 2"); button1 = new JButton("Button"); box = new JComboBox<>(); group = new ButtonGroup(); radio1 = new JRadioButton("Pepek"); radio2 = new JRadioButton("Namornik"); group.add(radio1); group.add(radio2); box.addItem("item1"); box.addItem("item2"); checkBox1 = new JCheckBox("Jarda"); checkBox2 = new JCheckBox("Kryštof"); textfield =new JTextField("adfadsfdsag"); slider = new JSlider(JSlider.VERTICAL, 0,10,5); slider.setMinorTickSpacing(1); slider.setMajorTickSpacing(5); slider.setPaintTicks(true); slider.setPaintLabels(true); bar = new JMenuBar(); menu = new JMenu("Menu"); item2 = new JMenu("2"); item1 = new JMenuItem("1"); item3 = new JMenuItem("3"); item4 = new JMenuItem("4"); item2a = new JMenuItem("a"); item2b = new JMenuItem("b"); listModel = new DefaultListModel<>(); listModel.addElement("Item3"); listModel.addElement("Item4"); list = new JList<>(listModel); item2.add(item2a); item2.add(item2b); menu.add(item1); menu.add(item2); menu.add(item3); menu.add(item4); bar.add(menu); add(bar); innerPanel.add(text1); innerPanel.add(text2); innerPanel.add(button1); innerPanel.add(box); innerPanel.add(textfield); innerPanel.add(checkBox1); innerPanel.add(checkBox2); innerPanel.add(radio1); innerPanel.add(radio2); innerPanel.add(slider); innerPanel.add(list); innerPanel.add(bar); add(innerPanel); setVisible(true); } public static void main(String[] args) { new GUI ("My app"); } }