Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.LocalTime;
- public class RadioGUI extends JFrame {
- ButtonGroup group = new ButtonGroup();
- private JTextArea textArea1;
- private JPanel panelMain;
- private JCheckBox checkBox1;
- private JRadioButton povinnéRadioButton;
- private JRadioButton nepovinnéRadioButton;
- private JButton pridejButton;
- public RadioGUI() {
- group.add(povinnéRadioButton);
- group.add(nepovinnéRadioButton);
- pridejButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- textArea1.append(String.valueOf(LocalDate.now()+ " " + LocalTime.now()+" "));
- if(checkBox1.isSelected()){
- textArea1.append("Splněno");
- }
- else {
- textArea1.append("Nesplněno");
- }
- if(povinnéRadioButton.isSelected()){
- textArea1.append("(povinné)\n");
- }
- else{
- textArea1.append("(nepovinné)\n");
- }
- }
- });
- }
- public static void main(String[] args) {
- RadioGUI gui = new RadioGUI();
- gui.setVisible(true);
- gui.setContentPane(gui.panelMain);
- gui.setTitle("úkoly");
- gui.setSize(800, 450);
- gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement