import javax.swing.*;
import java.awt.Color;
public class LokControl extends javax.swing.JApplet{
private static final long serialVersionUID = 1L;
private JFrame fenster;
private JPanel pLokControl;
private JRadioButton rVor, rRueck;
private JCheckBox cF1, cF2, cF3, cF4;
private JButton bNotAus;
private JSlider geschw;
public LokControl(String Name){
fenster = new JFrame(Name);
fenster.setSize(375,175);
fenster.setLocation(400,200);
fenster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenster.setLayout(null);
fenster.setVisible(true);
pLokControl = new JPanel();
pLokControl.setMinimumSize(new java.awt.Dimension(375, 175));
pLokControl.setBounds(0, 0, 375, 175);
pLokControl.setLayout(null);
bNotAus = new JButton();
bNotAus.setBackground(Color.red);
bNotAus.setBounds(275, 115, 80, 20);
bNotAus.setText("NotAus");
pLokControl.add(bNotAus);
rVor = new JRadioButton();
rVor.setBounds(200, 70, 100, 13);
rVor.setText("Vorwärts");
rVor.setSelected(true);
pLokControl.add(rVor);
rRueck = new JRadioButton();
rRueck.setBounds(60, 70, 100, 13);
rRueck.setText("Rückwärts");
pLokControl.add(rRueck);
cF1 = new JCheckBox();
cF1.setText("Funktion 1");
cF1.setFont(new java.awt.Font("Tahoma", 0, 12));
cF1.setBounds(20, 100, 120, 15);
pLokControl.add(cF1);
cF2 = new JCheckBox();
cF2.setText("Funktion 2");
cF2.setFont(new java.awt.Font("Tahoma", 0, 12));
cF2.setBounds(20, 120, 120, 15);
pLokControl.add(cF2);
cF3 = new JCheckBox();
cF3.setText("Funktion 1");
cF3.setFont(new java.awt.Font("Tahoma", 0, 12));
cF3.setBounds(140, 100, 120, 15);
pLokControl.add(cF3);
cF4 = new JCheckBox();
cF4.setText("Funktion 2");
cF4.setFont(new java.awt.Font("Tahoma", 0, 12));
cF4.setBounds(140, 120, 120, 15);
pLokControl.add(cF4);
geschw = new JSlider();
geschw.setBounds(65, 20, 220, 40);
geschw.setMaximum(14);
geschw.setMinimum(0);
geschw.setValue(0);
geschw.setPaintTicks(true);
geschw.setMajorTickSpacing(2);
geschw.setToolTipText("Geschwindigkeits-Regler");
geschw.setPaintLabels(true);
pLokControl.add(geschw);
fenster.getContentPane().add(pLokControl);
pLokControl.setVisible(true);
fenster.add(pLokControl);
geschw.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
switch (geschw.getValue()) {
case 0:
rVor.setEnabled(true);
rRueck.setEnabled(true);
break;
default:
rVor.setEnabled(false);
rRueck.setEnabled(false);
}
}
});
rVor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rRueck.setSelected(false);
}
});
rRueck.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rVor.setSelected(false);
}
});
bNotAus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rVor.setSelected(true);
rRueck.setSelected(false);
cF2.setSelected(false);
cF2.setSelected(false);
cF2.setSelected(false);
cF2.setSelected(false);
cF1.setEnabled(false);
cF2.setEnabled(false);
cF3.setEnabled(false);
cF4.setEnabled(false);
rVor.setEnabled(false);
geschw.setValue(0);
}
});
}
}