import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
*
* Beschreibung
*
* @version 1.0 vom 05.01.2017
* @author
*/
public class Netto extends JFrame {
// Anfang Attribute
private JRadioButton jRadioButton1 = new JRadioButton();
private JRadioButton jRadioButton2 = new JRadioButton();
private JLabel jLabel3 = new JLabel();
private JLabel jLabel4 = new JLabel();
private JTextField jTextField1 = new JTextField();
private JTextField jTextField2 = new JTextField();
private JLabel jLabel5 = new JLabel();
private JLabel jLabel6 = new JLabel();
private JRadioButton jRadioButton3 = new JRadioButton();
private JRadioButton jRadioButton4 = new JRadioButton();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
// Ende Attribute
public Netto(String title) {
// Frame-Initialisierung
super(title);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int frameWidth = 546;
int frameHeight = 217;
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);
setResizable(false);
Container cp = getContentPane();
cp.setLayout(null);
// Anfang Komponenten
jRadioButton1.setBounds(16, 16, 60, 20);
jRadioButton1.setText("Netto");
jRadioButton1.setOpaque(false);
cp.add(jRadioButton1);
jRadioButton2.setBounds(160, 16, 60, 20);
jRadioButton2.setText("Brutto");
jRadioButton2.setOpaque(false);
cp.add(jRadioButton2);
jRadioButton3.setBounds(304, 72, 52, 20);
jRadioButton3.setText("7%");
jRadioButton3.setOpaque(false);
cp.add(jRadioButton3);
jRadioButton4.setBounds(304, 136, 60, 20);
jRadioButton4.setText("19%");
jRadioButton4.setOpaque(false);
cp.add(jRadioButton4);
/* Button Gruppe
*
*
*/
ButtonGroup gruppe1 = new ButtonGroup();
gruppe1.add(jRadioButton1);
gruppe1.add(jRadioButton2);
ButtonGroup gruppe2 = new ButtonGroup();
gruppe2.add(jRadioButton3);
gruppe2.add(jRadioButton4);
/*
*
*
*/
// jLabels
jLabel3.setBounds(16, 72, 100, 20);
jLabel3.setText("Betrag:");
cp.add(jLabel3);
jLabel4.setBounds(16, 136, 100, 20);
jLabel4.setText("fälliger Betrag:");
cp.add(jLabel4);
jTextField1.setBounds(160, 72, 100, 20);
cp.add(jTextField1);
jTextField2.setBounds(160, 136, 100, 20);
cp.add(jTextField2);
jLabel5.setBounds(276, 72, 20, 20);
jLabel5.setText("€");
jLabel5.setFont(new Font("Arial", Font.BOLD, 16));
cp.add(jLabel5);
jLabel6.setBounds(276, 136, 20, 20);
jLabel6.setText("€");
jLabel6.setFont(new Font("Arial", Font.BOLD, 16));
cp.add(jLabel6);
jButton1.setBounds(376, 16, 153, 97);
jButton1.setText("Berechnen");
jButton1.setMargin(new Insets(2, 2, 2, 2));
// jButtons
jButton1.addActionListener (new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
cp.add(jButton1);
jButton2.setBounds(376, 136, 153, 33);
jButton2.setText("Beenden");
jButton2.setMargin(new Insets(2, 2, 2, 2));
jButton2.addActionListener (new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton2_ActionPerformed(evt);
}
});
cp.add(jButton2);
// Ende Komponenten
setVisible(true);
} // end of public Netto
// Anfang Methoden
public static void main(String[] args) {
new Netto("Netto");
} // end of main
public void jButton1_ActionPerformed(ActionEvent evt) {
// TODO hier Quelltext einfügen
double betrag = Double.parseDouble(jTextField1.getText());
Fachklasse objekt1 = new Fachklasse();
{
if (jRadioButton1.isSelected() && jRadioButton3.isSelected()) {
double wert = objekt1.plus7(betrag);
jTextField2.setText(Double.toString(wert));
} else {
if (jRadioButton1.isSelected() && jRadioButton4.isSelected()) {
double wert = objekt1.plus19(betrag);
jTextField2.setText(Double.toString(wert));
} // end of if
else {
if (jRadioButton2.isSelected() && jRadioButton3.isSelected()) {
double wert = objekt1.minus7(betrag);
jTextField2.setText(Double.toString(wert));
} // end of if
else
if (jRadioButton2.isSelected() && jRadioButton4.isSelected()) {
double wert = objekt1.minus19(betrag);
jTextField2.setText(Double.toString(wert));
} // end of if
} // end of if-else
} // end of if-else
} // end of if
} // end of jButton1_ActionPerformed
public void jButton2_ActionPerformed(ActionEvent evt) {
// TODO hier Quelltext einfügen
System.exit(0);
} // end of jButton2_ActionPerformed
// Ende Methoden
} // end of class Netto