Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package grafika;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- /**
- * Created by urosrt4515 on 12/11/2018.
- */
- public class Prozor extends JFrame{
- public Prozor(){
- setTitle("Vezba 8");
- setSize(400,400);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Container c=getContentPane();
- c.setLayout(new BorderLayout());
- JButton btn1=new JButton("Dugme 1");
- c.add("North",btn1);
- JPanel p=new JPanel();
- p.setLayout(new GridLayout(4,1));
- JRadioButton rb1=new JRadioButton("muski");
- p.add(rb1);
- JRadioButton rb2=new JRadioButton("muski");
- p.add(rb2);
- ButtonGroup bgPol=new ButtonGroup();
- bgPol.add(rb1);
- bgPol.add(rb2);
- JCheckBox cb1=new JCheckBox("Izbor1");
- p.add(cb1);
- JCheckBox cb2=new JCheckBox("Izbor1");
- p.add(cb2);
- ItemListener itPol=new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getSource() instanceof JRadioButton) {
- if (rb1.isSelected())
- System.out.println("Pol muski");
- else if (rb2.isSelected())
- System.out.println("Pol zemski");
- } else {
- if(cb1.isSelected())
- System.out.println("Izabrana oopcija 1");
- if(cb2.isSelected())
- System.out.println("Izabrana oopcija 2");
- }
- }
- };
- rb1.addItemListener(itPol);
- rb2.addItemListener(itPol);
- cb1.addItemListener(itPol);
- cb2.addItemListener(itPol);
- c.add("Center", p);
- JLabel lblv=new JLabel("Vreme:60");
- c.add("West", lblv);
- new Odbrojavanje(lblv).start();
- setVisible(true);
- }
- }
- -------------------------------------
- package glavni;
- import grafika.Prozor;
- /**
- * Created by urosrt4515 on 12/11/2018.
- */
- public class Program {
- public static void main(String[] args) {
- Prozor p=new Prozor();
- }
- }
- -------------------------------------
- package grafika;
- import javax.swing.*;
- /**
- * Created by urosrt4515 on 12/11/2018.
- */
- public class Odbrojavanje extends Thread{
- private JLabel lblVreme;
- public Odbrojavanje(JLabel lbl){
- this.lblVreme=lbl;
- }
- public void run(){
- for (int i=60;i>=0;i--){
- lblVreme.setText("Vreme:"+i);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement