Ventile import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class Ventile extends JFrame { // Anfang Attribute private JTextField jTextField1 = new JTextField(); private JLabel jLabel1 = new JLabel(); private JButton jButton2 = new JButton(); private JButton jButton3 = new JButton(); private JButton jButton4 = new JButton(); private JButton jButton5 = new JButton(); private JButton jButton6 = new JButton(); private JButton jButton1 = new JButton(); // Ende Attribute public Ventile() { // Frame-Initialisierung super(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); int frameWidth = 300; int frameHeight = 300; setSize(frameWidth, frameHeight); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); int x = (d.width - getSize().width) / 2; int y = (d.height - getSize().height) / 2; setLocation(x, y); setTitle("Ventile"); setResizable(false); Container cp = getContentPane(); cp.setLayout(null); // Anfang Komponenten jTextField1.setBounds(0, 216, 294, 28); cp.add(jTextField1); jLabel1.setBounds(16, 16, 94, 20); jLabel1.setText("gedrückt =offen"); cp.add(jLabel1); jButton2.setBounds(8, 56, 75, 25); jButton2.setText("Ventil 1"); jButton2.setMargin(new Insets(2, 2, 2, 2)); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2_ActionPerformed(evt); } }); cp.add(jButton2); jButton3.setBounds(8, 120, 75, 25); jButton3.setText("Ventil 2"); jButton3.setMargin(new Insets(2, 2, 2, 2)); jButton3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton3_ActionPerformed(evt); } }); cp.add(jButton3); jButton4.setBounds(88, 96, 75, 25); jButton4.setText("Ventil 3"); jButton4.setMargin(new Insets(2, 2, 2, 2)); jButton4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton4_ActionPerformed(evt); } }); cp.add(jButton4); jButton5.setBounds(168, 72, 75, 25); jButton5.setText("Ventil 4"); jButton5.setMargin(new Insets(2, 2, 2, 2)); jButton5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton5_ActionPerformed(evt); } }); cp.add(jButton5); jButton6.setBounds(168, 128, 75, 25); jButton6.setText("Ventil 5"); jButton6.setMargin(new Insets(2, 2, 2, 2)); jButton6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton6_ActionPerformed(evt); } }); cp.add(jButton6); jButton1.setBounds(96, 176, 75, 25); jButton1.setText("jButton1"); jButton1.setMargin(new Insets(2, 2, 2, 2)); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1_ActionPerformed(evt); } }); cp.add(jButton1); // Ende Komponenten setVisible(true); } // end of public Ventile boolean a=false; boolean b=false; boolean c=false; boolean d=false; boolean e=false; // Anfang Methoden public static void main(String[] args) { new Ventile(); } // end of main public void jButton2_ActionPerformed(ActionEvent evt) { a=true; System.out.print("Ventil 1 ist offen"); } // end of jButton2_ActionPerformed public void jButton3_ActionPerformed(ActionEvent evt) { b=true; System.out.print("Ventil 2 ist offen"); } // end of jButton3_ActionPerformed public void jButton4_ActionPerformed(ActionEvent evt) { c=true; System.out.print("Ventil 3 ist offen"); } // end of jButton4_ActionPerformed public void jButton5_ActionPerformed(ActionEvent evt) { d=true; System.out.print("Ventil 4 ist offen"); } // end of jButton5_ActionPerformed public void jButton6_ActionPerformed(ActionEvent evt) { e=true; System.out.print("Ventil 5 ist offen"); } // end of jButton6_ActionPerformed public void jButton1_ActionPerformed(ActionEvent evt) { if (c) { if (a||b) { if (d||e) { jTextField1.setText("Die Külflusigkeit fliest durch die Ventile fließen"); } // end of if else { jTextField1.setText("Die Külflusigkeit fliest nicht durch die Ventile fließen"); } // end of if-else } // end of if else { jTextField1.setText("Die Külflusigkeit fliest nicht durch die Ventile fließen"); } // end of if-else } // end of if else { jTextField1.setText("Die Külflusigkeit fliest nicht durch die Ventile fließen"); } // end of if-else a=false; b=false; c=false; d=false; e=false; System.out.print("alle Ventile sind wieder geschlossen"); } // end of jButton1_ActionPerformed // Ende Methoden } // end of class Ventile