import java.awt.*;
import java.math.*;
import java.io.IOException;
import java.io.*;
import java.util.*;
import java.io.FileOutputStream;
import java.io.File;
public class Frame1 extends Frame
{
public Frame1()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setBackground(java.awt.Color.darkGray);
setSize(687,341);
setVisible(false);
button1.setLabel("Berechne");
add(button1);
button1.setBackground(java.awt.Color.gray);
button1.setFont(new Font("Dialog", Font.BOLD, 20));
button1.setBounds(216,156,180,36);
add(tf1);
tf1.setBackground(new java.awt.Color(128,128,255));
tf1.setFont(new Font("Dialog", Font.BOLD, 20));
tf1.setBounds(24,48,144,36);
l1.setText("Vorher");
l1.setAlignment(java.awt.Label.CENTER);
add(l1);
l1.setForeground(java.awt.Color.red);
l1.setFont(new Font("Dialog", Font.BOLD, 25));
l1.setBounds(12,12,156,24);
add(tf2);
tf2.setBackground(new java.awt.Color(128,128,255));
tf2.setFont(new Font("Dialog", Font.BOLD, 20));
tf2.setBounds(24,144,144,36);
l2.setText("Nachher");
l2.setAlignment(java.awt.Label.CENTER);
add(l2);
l2.setForeground(java.awt.Color.red);
l2.setFont(new Font("Dialog", Font.BOLD, 25));
l2.setBounds(24,108,144,24);
label1.setText("=>");
add(label1);
label1.setFont(new Font("Dialog", Font.ITALIC, 40));
label1.setBounds(168,96,48,36);
button2.setLabel("Eingaben Löschen");
add(button2);
button2.setBackground(java.awt.Color.gray);
button2.setFont(new Font("Dialog", Font.BOLD, 20));
button2.setBounds(216,204,180,36);
label2.setText("Anstieg in %");
label2.setAlignment(java.awt.Label.CENTER);
add(label2);
label2.setForeground(java.awt.Color.red);
label2.setFont(new Font("Dialog", Font.BOLD, 25));
label2.setBounds(216,48,180,48);
l4.setAlignment(java.awt.Label.CENTER);
add(l4);
l4.setBackground(java.awt.Color.gray);
l4.setFont(new Font("Dialog", Font.BOLD, 14));
l4.setBounds(216,96,180,48);
button4.setLabel("MwST Rechner");
add(button4);
button4.setBackground(java.awt.Color.lightGray);
button4.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 12));
button4.setBounds(552,300,132,36);
button3.setLabel("Prozentualer Anstieg");
add(button3);
button3.setBackground(java.awt.Color.lightGray);
button3.setFont(new Font("Dialog", Font.BOLD, 12));
button3.setBounds(552,264,132,36);
label3.setText("Bruttogehalt");
add(label3);
label3.setBounds(564,36,8,8);
setTitle("AWT Application");
//}}
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
button1.addActionListener(lSymAction);
button2.addActionListener(lSymAction);
button4.addActionListener(lSymAction);
button3.addActionListener(lSymAction);
//}}
}
public Frame1(String title)
{
this();
setTitle(title);
}
/**
* Shows or hides the component depending on the boolean flag b.
* @param b if true, show the component; otherwise, hide the component.
* @see java.awt.Component#isVisible
*/
public void setVisible(boolean b)
{
if(b)
{
setLocation(50, 50);
}
super.setVisible(b);
}
static public void main(String args[])
{
// File f = new File ("test.txt");
//try {
//Filewriter fw = new FileWriter(f);
// fw.write(""+y + " = " +c +"%");
// fw.close();
{
}
try
{
//Create a new instance of our application's frame, and make it visible.
(new Frame1()).setVisible(true);
}
catch (Throwable tf3)
{
System.err.println(tf3);
tf3.printStackTrace();
//Ensure the application exits with an error condition.
System.exit(1);
}
}
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(getInsets().left, getInsets().top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{DECLARE_CONTROLS
java.awt.Button button1 = new java.awt.Button();
java.awt.TextField tf1 = new java.awt.TextField();
java.awt.Label l1 = new java.awt.Label();
java.awt.TextField tf2 = new java.awt.TextField();
java.awt.Label l2 = new java.awt.Label();
java.awt.Label label1 = new java.awt.Label();
java.awt.Button button2 = new java.awt.Button();
java.awt.Label label2 = new java.awt.Label();
java.awt.Label l4 = new java.awt.Label();
java.awt.Button button4 = new java.awt.Button();
java.awt.Button button3 = new java.awt.Button();
java.awt.Label label3 = new java.awt.Label();
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == Frame1.this)
Frame1_WindowClosing(event);
}
}
void Frame1_WindowClosing(java.awt.event.WindowEvent event)
{
// to do: code goes here.
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == button1)
button1_ActionPerformed(event);
else if (object == button2)
button2_ActionPerformed(event);
if (object == button4)
button4_ActionPerformed(event);
else if (object == button3)
button3_ActionPerformed(event);
}
}
void button1_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
String Brutto = new String("Bruttogehalt");
String label=l1.getText();
String labeltest=label3.getText();
String Vorher = new String("Vorher");
double a = Double.parseDouble(tf1.getText());
double b = Double.parseDouble(tf2.getText());
if (label.equals(Vorher))
{
double c = (b/a-1)*100;
c = Math.round(100.0 * c) / 100.0;
l4.setText(" = " +c +"%");
}
if (label.equals(label3))
{
double xx = a/100*19;
double yy = a-xx;
l4.setText(""+yy);
}
}
void button2_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
tf1.setText("");
tf2.setText("");
l4.setText("");
}
void button4_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here
l1.setText("Bruttobetrag");
l2.setText("Nettobetrag");
}
void button3_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
l1.setText("Vorher");
l2.setText("Nachher");
}
}