import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Summary description for gehalt
*
*/
public class gehalt extends JFrame
{
// Variables declaration
private JCheckBox jCheckBox1;
private JCheckBox jCheckBox2;
private JCheckBox jCheckBox3;
private JRadioButton jRadioButton1;
private JTextField jTextField1;
private JTextField jTextField2;
private JTextField jTextField3;
private JTextField jTextField4;
private JComboBox jComboBox1;
private JComboBox jComboBox2;
private JPanel contentPane;
private JButton jButton1;
private JLabel jLabel1;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4;
double argument;
double steuer;
String combo1;
double kranken;
double ergebnis;
double arbeit;
double rente;
double kirche;
// End of variables declaration
public gehalt()
{
super();
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//
this.setVisible(true);
}
private void initializeComponent()
{
jCheckBox1 = new JCheckBox();
jCheckBox2 = new JCheckBox();
jCheckBox3 = new JCheckBox();
jRadioButton1 = new JRadioButton();
jTextField1 = new JTextField();
jTextField2 = new JTextField();
jTextField3 = new JTextField();
jTextField4 = new JTextField();
jComboBox1 = new JComboBox();
jComboBox2 = new JComboBox();
jButton1 = new JButton();
jLabel1 = new JLabel();
jLabel2 = new JLabel();
jLabel3 = new JLabel();
jLabel4 = new JLabel();
contentPane = (JPanel)this.getContentPane();
//
// jCheckBox1
//
jCheckBox1.setText("Rentenversicherungspflicht");
jCheckBox1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e)
{
jCheckBox1_itemStateChanged(e);
if (jCheckBox1.isSelected())
{double rente = argument*0.01;}
}
});
//
// jCheckBox2
//
jCheckBox2.setText("Arbeitslosenversicherung");
jCheckBox2.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e)
{
jCheckBox2_itemStateChanged(e);
if (jCheckBox2.isSelected())
{double arbeit = argument*0.02;}
}
});
//
// jCheckBox3
//
jCheckBox3.setText("Krankenkasse");
jCheckBox3.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e)
{
jCheckBox3_itemStateChanged(e);
/*if (jCheckBox3.isSelected())
{double kranken = Double.parseDouble( jTextField3.getText());}*/
}
});
//
// jRadioButton1
//
jRadioButton1.setText("Kirchensteuer");
jRadioButton1.setSelected(true);
jRadioButton1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e)
{
jRadioButton1_itemStateChanged(e);
/*if (jRadioButton1.isSelected())
{double kirche = argument*0.01;}*/
}
});
//
// jTextField1
//
jTextField1.setText("");
jTextField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1_actionPerformed(e);
//double argument = Double.parseDouble( jTextField1.getText());
}
});
//
// jTextField2
//
jTextField2.setText("");
jTextField2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField2_actionPerformed(e);
}
});
//
// jTextField3
//
jTextField3.setText("");
jTextField3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField3_actionPerformed(e);
}
});
//
// jTextField4
//
jTextField4.setText("jTextField4");
jTextField4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField4_actionPerformed(e);
}
});
//
// jComboBox1
//
jComboBox1.addItem("Steuerklasse 1");
jComboBox1.addItem("Steuerklasse 2");
jComboBox1.addItem("Steuerklasse 3");
jComboBox1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jComboBox1_actionPerformed(e);
/* String combo1 = String.valueOf(jComboBox1.getSelectedItem());
if (combo1.equals("Steuerklasse 1"))
{double steuer = 0.4;}
if (combo1.compareTo("Steuerklasse 2")==0)
{double steuer = 0.3;}
if (combo1=="Steuerklasse 3")
{double steuer = 0.2;}
else
steuer = 0.1;*/
}
});
//
// jComboBox2
//
jComboBox2.addItem("0");
jComboBox2.addItem("1");
jComboBox2.addItem("2");
jComboBox2.addItem("3");
jComboBox2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jComboBox2_actionPerformed(e);
}
});
//
// jButton1
//
jButton1.setText("Berechnen");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
double argument = Double.parseDouble( jTextField1.getText());
String combo1 = String.valueOf(jComboBox1.getSelectedItem());
if (combo1.compareTo("Steuerklasse 1")==0)
{double steuer = 4;}
if (combo1.equals("Steuerklasse 2"))
{double steuer = 0.3;}
if (combo1.equals("Steuerklasse 3"))
{double steuer = 0.2;}
else
steuer = 0.1;
if (jRadioButton1.isSelected())
{double kirche = argument*0.01;}
if (jCheckBox3.isSelected())
{double kranken = Double.parseDouble( jTextField3.getText());}
double ergebnis = argument-(argument*(steuer/100));//(argument - (argument*steuer)-(argument*kranken) - kirche);
jTextField4.setText(Double.toString(ergebnis));
}
});
//
// jLabel1
//
jLabel1.setText("Bruttolohn");
//
// jLabel2
//
jLabel2.setText("Steuerklasse");
//
// jLabel3
//
jLabel3.setText("Zahl Kinderfreibeträge");
//
// jLabel4
//
jLabel4.setText("Freibetrag");
//
// contentPane
//
contentPane.setLayout(null);
addComponent(contentPane, jCheckBox1, 245,9,160,24);
addComponent(contentPane, jCheckBox2, 245,44,161,24);
addComponent(contentPane, jCheckBox3, 245,79,96,24);
addComponent(contentPane, jRadioButton1, 245,148,139,24);
addComponent(contentPane, jTextField1, 120,10,100,22);
addComponent(contentPane, jTextField2, 120,116,100,22);
addComponent(contentPane, jTextField3, 245,115,77,22);
addComponent(contentPane, jTextField4, 245, 215, 80, 22);
addComponent(contentPane, jComboBox1, 120,46,100,22);
addComponent(contentPane, jComboBox2, 120,80,54,22);
addComponent(contentPane, jButton1, 120,212,94,28);
addComponent(contentPane, jLabel1, 10,9,60,18);
addComponent(contentPane, jLabel2, 10,44,77,18);
addComponent(contentPane, jLabel3, 10,79,114,18);
addComponent(contentPane, jLabel4, 10,116,60,18);
//
// gehalt
//
this.setTitle("gehalt - extends JFrame");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(472, 300));
}
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
private void jCheckBox1_itemStateChanged(ItemEvent e)
{
System.out.println("\njCheckBox1_itemStateChanged(ItemEvent e) called.");
System.out.println(">>" + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected":"unselected"));
// TODO: Add any handling code here
}
private void jCheckBox2_itemStateChanged(ItemEvent e)
{
System.out.println("\njCheckBox2_itemStateChanged(ItemEvent e) called.");
System.out.println(">>" + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected":"unselected"));
// TODO: Add any handling code here
}
private void jCheckBox3_itemStateChanged(ItemEvent e)
{
System.out.println("\njCheckBox3_itemStateChanged(ItemEvent e) called.");
System.out.println(">>" + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected":"unselected"));
// TODO: Add any handling code here
}
private void jRadioButton1_itemStateChanged(ItemEvent e)
{
System.out.println("\njRadioButton1_itemStateChanged(ItemEvent e) called.");
System.out.println(">>" + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected":"unselected"));
// TODO: Add any handling code here
}
private void jTextField1_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jTextField2_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField2_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jTextField3_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField3_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jTextField4_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField4_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jComboBox1_actionPerformed(ActionEvent e)
{
System.out.println("\njComboBox1_actionPerformed(ActionEvent e) called.");
Object o = jComboBox1.getSelectedItem();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
// TODO: Add any handling code here for the particular object being selected
}
private void jComboBox2_actionPerformed(ActionEvent e)
{
System.out.println("\njComboBox2_actionPerformed(ActionEvent e) called.");
Object o = jComboBox2.getSelectedItem();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
// TODO: Add any handling code here for the particular object being selected
}
private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here