Podlaczenie GUI

0

Witam chciałem zrobić działanie bramki logicznej AND i utknąłem na robieniu poprawek:

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;


public class AND extends JFrame implements ActionListener {
	
	private JLabel jLabel0;
	private JButton jButton5;
	private JButton jButton4;
	private JButton jButton3;
	private JButton jButton2;
	private JButton jButton1;
	private JButton jButton0;
	 JTextField jTextField1;
	 JTextField jTextField0;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JCheckBox jCheckBox0;
	private JCheckBox jCheckBox1;
	private JTextField jTextField2;
	private JLabel jLabel4;
	public AND() {
		initComponents();
		paintGate();
	}

	private void initComponents() {
		
		setTitle("BRAMKA LOGICZNA \\\\ AND");
		setLayout(new GroupLayout());
		
		jLabel0 = new JLabel();
		jLabel0.setText("BRAMKI LOGICZNE - BRAMKA AND");
		add(jLabel0, new Constraints(new Leading(4, 201, 10, 10), new Leading(5, 10, 10)));
		
		jLabel2 = new JLabel();
		jLabel2.setText("a");
		add(jLabel2, new Constraints(new Leading(88, 17, 12, 12), new Leading(88, 12, 12)));
		
		jLabel3 = new JLabel();
		jLabel3.setText("b");
		add(jLabel3, new Constraints(new Leading(88, 17, 12, 12), new Leading(145, 12, 12)));
		
		jLabel4 = new JLabel();
		jLabel4.setText("wynik");
		add(jLabel4, new Constraints(new Leading(263, 12, 12), new Leading(70, 12, 12)));
		
		jButton0 = new JButton();
		jButton0.setText("0");
		jButton0.addActionListener(this);
		add(jButton0, new Constraints(new Leading(48, 79, 12, 12), new Leading(257, 12, 12)));
		
		jButton1 = new JButton();
		jButton1.setText("1");
		jButton1.addActionListener(this);
		add(jButton1, new Constraints(new Leading(133, 82, 12, 12), new Leading(257, 12, 12)));
		
		jButton2 = new JButton();
		jButton2.setText("Result");
		jButton2.addActionListener(this);
		add(jButton2, new Constraints(new Leading(220, 81, 12, 12), new Leading(257, 12, 12)));
		
		jButton3 = new JButton();
		jButton3.setText("RESTART");
		jButton3.addActionListener(this);
		add(jButton3, new Constraints(new Leading(48, 253, 10, 10), new Leading(224, 27, 12, 12)));
		
		jButton4 = new JButton();
		jButton4.setText("Czysc a");
		jButton4.addActionListener(this);
		add(jButton4, new Constraints(new Leading(26, 79, 12, 12), new Leading(63, 17, 12, 12)));
		
		jButton5 = new JButton();
		jButton5.setText("Czysc b");
		jButton5.addActionListener(this);
		add(jButton5, new Constraints(new Leading(25, 80, 12, 12), new Leading(170, 17, 12, 12)));
		
		
		jCheckBox0 = new JCheckBox();
		jCheckBox0.addActionListener(this);
		add(jCheckBox0, new Constraints(new Leading(10, 26, 12, 12), new Leading(86, 12, 12)));
		
		jCheckBox1 = new JCheckBox();
		jCheckBox1.addActionListener(this);
		add(jCheckBox1, new Constraints(new Leading(10, 12, 12), new Leading(144, 12, 12)));
		
		jTextField0 = new JTextField();
		add(jTextField0, new Constraints(new Leading(48, 34, 12, 12), new Leading(86, 21, 10, 10)));
		
		jTextField1 = new JTextField();
		add(jTextField1, new Constraints(new Leading(48, 34, 12, 12), new Leading(144, 12, 12)));
		
		jTextField2 = new JTextField();
		add(jTextField2, new Constraints(new Leading(258, 43, 10, 10), new Leading(104, 35, 10, 10)));
		
		setSize(660, 336);
	}
	
	public void actionPerformed(ActionEvent e) {
		Object ob = e.getSource();
		if(ob == jButton2){
			new Cframe().setVisible(true);

}

	public void paintGate(){

		}
}

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;


//VS4E -- DO NOT REMOVE THIS LINE!
public class Cframe extends JFrame implements ActionListener {

	private static final long serialVersionUID = 1L;
	private JRadioButton jRadioButton0;
	private JRadioButton jRadioButton1;
	private JButton jButton1;
	private JButton jButton0;
	public int change=0;
	AND and = new AND();
	public Cframe() {
		initComponents();
	}

	private void initComponents() {
		setTitle("CListener");
		setLayout(new GroupLayout());
		jRadioButton0 = new JRadioButton();
		jRadioButton0.setText("Zmien wartosc a");
		jRadioButton0.addActionListener(this);
		add(jRadioButton0, new Constraints(new Leading(12, 12, 12), new Leading(55, 10, 10)));
		
		jRadioButton1 = new JRadioButton();
		jRadioButton1.setText("Zmien wartosc b");
		jRadioButton1.addActionListener(this);
		add(jRadioButton1,new Constraints(new Leading(12, 12, 12), new Leading(105, 10, 10)));
		
		jButton1 = new JButton();
		jButton1.setText("CANEL");
		jButton1.addActionListener(this);
		add(jButton1,new Constraints(new Leading(153, 81, 10, 10), new Leading(151, 12, 12)));
		
		jButton0 = new JButton();
		jButton0.setText("OK");
		jButton0.addActionListener(this);
		add(jButton0,new Constraints(new Leading(58, 79, 10, 10), new Leading(151, 10, 10)));
		
		setSize(320, 221);
	}
	
	public void actionPerformed(ActionEvent e) {
		Object ob = e.getSource();
		if(ob == jButton0){
			if(jRadioButton0.isSelected()){
				and.jTextField0.setFont(new Font("Arial",Font.BOLD,20));
				and.jTextField0.setText("");
				and.jTextField0.setEnabled(true);
				setVisible(false);
			}
			else if(jRadioButton1.isSelected()){
				and.jTextField1.setFont(new Font("Arial",Font.BOLD,20));
				and.jTextField1.setText("");
				and.jTextField1.setEnabled(true);
				setVisible(false);
			}
		}
		if(ob == jButton1){
			setVisible(false);
		}
	}
}

Nie wiem jak wykonać jTextfields z klasy AND klasą C.... bardzo proszę o sprostowanie jeżeli robię głupoty

0

Jest ktoś w stanie pomóc?

0

Temat do zamknięcia.

1 użytkowników online, w tym zalogowanych: 0, gości: 1