Java-2 2016 Hafta-5 Örnek-2

java2_2016_hafta5_ornek2

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class onaykutusu implements ActionListener
{
JCheckBox jckb;
JLabel jlab;
public onaykutusu()
{
	JFrame jfrm = new JFrame("Onay Kutusu Örneği");
	jfrm.setSize(150,150);
	jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	jfrm.setLayout(new FlowLayout());

	JPanel jpn = new JPanel();
	jpn.setPreferredSize( new Dimension(140,140));
	
	jckb = new JCheckBox("Onay");
	JButton jbtn = new JButton("Kontrol Et");
	jbtn.addActionListener(this);
	jbtn.setActionCommand("buton");
	
	jckb.addActionListener(this);
	jckb.setActionCommand("ckb");
	
	jlab = new JLabel("--");
	
	jpn.add(jckb);
	jpn.add(jbtn);
	jpn.add(jlab);
	
	jfrm.add(jpn);
	jfrm.setVisible(true);
}

public void actionPerformed(ActionEvent ae)
{
/*	if(jckb.isSelected())
		jlab.setText("Teşekkürler");
	else
		jlab.setText("Onay Vermelisiniz!");*/
		
	jlab.setText(ae.getActionCommand());		
	


}

public static void main(String[] args)
{
	new onaykutusu();
}


}

 

Share