Hey Leute!
Hab mal wieder ein kleines Problem. Ich benutze Java Editor und wenn ich auf .jar erzeugen gehe kommt:
Jar-Aufruf: C:\Programme\Java\jdk1.6.0_17\bin\java.exe -cfvm Taschenrechner.jar C:\DOKUME~1\Janosch\LOKALE~1\Temp\MANIFEST.MF *.class
Could not create the Java virtual machine.
Unrecognized option: -cfvm
Das ist der Code für einen primitiven Taschenrechner. Ich weiß manche Klassen werden gar nicht aufgerufen ist aber noch in Entwicklung.
Mfg
Janosch
Hab mal wieder ein kleines Problem. Ich benutze Java Editor und wenn ich auf .jar erzeugen gehe kommt:
Jar-Aufruf: C:\Programme\Java\jdk1.6.0_17\bin\java.exe -cfvm Taschenrechner.jar C:\DOKUME~1\Janosch\LOKALE~1\Temp\MANIFEST.MF *.class
Could not create the Java virtual machine.
Unrecognized option: -cfvm
Java:
import java.awt.*;
import java.awt.Toolkit;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.*;
import javax.swing.event.*;
import java.util.Random;
/**
*
* Taschenrechner
*
* @version 1.0 vom 25.02.2010
*
*/
public class Taschenrechner extends JFrame {
// Anfang Attribute
private JTextField Wert1 = new JTextField();
private JTextField Wert2 = new JTextField();
private JButton PlusButton = new JButton();
private JButton minusButton = new JButton();
private JButton malButton = new JButton();
private JButton divButton = new JButton();
private JButton ExButton = new JButton();
private JButton exButton1 = new JButton();
char c;
private JButton sinButton = new JButton();
private JButton jButton1 = new JButton();
private JButton EndeButton = new JButton();
private JButton cosButton = new JButton();
private JLabel Ausgabe = new JLabel();
private JButton Reset = new JButton();
private JButton tanButton = new JButton();
private JButton Zwischenablage = new JButton();
private JButton Hinweise = new JButton();
private JFrame fenster;
private int dw1;
private int dw2;
private JButton Random = new JButton();
private JButton Notizen = new JButton();
// Ende Attribute
// EndeButton Attribute
public Taschenrechner(String title) {
// Frame-Initialisierung
super(title);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int frameWidth = 436;
int frameHeight = 299;
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);
Container cp = getContentPane();
cp.setLayout(null);
// Anfang Komponenten
Wert1.setBounds(8, 8, 185, 24);
Wert1.setText("Wert1");
cp.add(Wert1);
Wert1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
Wert1.setText("");
}
});
Wert2.setBounds(232, 8, 185, 24);
Wert2.setText("Wert2");
cp.add(Wert2);
Wert2.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
Wert2.setText("");
}
});
PlusButton.setBounds(8, 48, 41, 25);
PlusButton.setText("+");
PlusButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
PlusButton_ActionPerformed(evt);
}
});
cp.add(PlusButton);
minusButton.setBounds(64, 48, 41, 25);
minusButton.setText("-");
minusButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
minusButton_ActionPerformed(evt);
}
});
cp.add(minusButton);
malButton.setBounds(120, 48, 41, 25);
malButton.setText("*");
malButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
malButton_ActionPerformed(evt);
}
});
cp.add(malButton);
divButton.setBounds(224, 48, 65, 25);
divButton.setText("easd");
divButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
divButton_ActionPerformed(evt);
}
});
divButton.setEnabled(true);
cp.add(divButton);
ExButton.setBounds(296, 48, 49, 25);
ExButton.setText("^x");
ExButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ExButton_ActionPerformed(evt);
}
});
cp.add(ExButton);
exButton1.setBounds(352, 48, 65, 25);
exButton1.setText("1/x^");
exButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
exButton1_ActionPerformed(evt);
}
});
cp.add(exButton1);
sinButton.setBounds(208, 88, 65, 25);
sinButton.setText("sin()");
sinButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
sinButton_ActionPerformed(evt);
}
});
cp.add(sinButton);
jButton1.setBounds(8, 216, 113, 41);
jButton1.setText("Übernehmen");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
cp.add(jButton1);
EndeButton.setBounds(296, 216, 121, 41);
EndeButton.setText("Exit");
EndeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
EndeButton_ActionPerformed(evt);
}
});
cp.add(EndeButton);
// EndeButton Komponenten
setResizable(false);
setVisible(true);
cosButton.setBounds(280, 88, 65, 25);
cosButton.setText("cos()");
cosButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
cosButton_ActionPerformed(evt);
}
});
cp.add(cosButton);
Ausgabe.setBounds(0, 144, 55, 16);
Ausgabe.setText("Ausgabe");
Ausgabe.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
Ausgabe.setHorizontalAlignment(SwingConstants.CENTER);
cp.add(Ausgabe);
Reset.setBounds(168, 216, 113, 41);
Reset.setText("Reset");
Reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Reset_ActionPerformed(evt);
}
});
cp.add(Reset);
tanButton.setBounds(352, 88, 65, 25);
tanButton.setText("tan()");
tanButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
tanButton_ActionPerformed(evt);
}
});
cp.add(tanButton);
Zwischenablage.setBounds(296, 184, 121, 25);
Zwischenablage.setText("Zwischenablage");
Zwischenablage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Zwischenablage_ActionPerformed(evt);
}
});
cp.add(Zwischenablage);
Hinweise.setBounds(8, 88, 113, 25);
Hinweise.setText("Hinweise");
Hinweise.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Hinweise_ActionPerformed(evt);
}
});
cp.add(Hinweise);
Random.setBounds(112, -32, 81, 33);
Random.setText("Random");
Random.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Random_ActionPerformed(evt);
}
});
cp.add(Random);
Notizen.setBounds(184, 184, 97, 25);
Notizen.setText("Notizen");
Notizen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Notizen_ActionPerformed(evt);
}
});
cp.add(Notizen);
// Ende Komponenten
}
// Anfang Methoden
public void PlusButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
String w2 = Wert2.getText();
w1.trim();
w2.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
double dw2 = Double.valueOf(w2).doubleValue();
Ausgabe.setText("" + (dw2 + dw1));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void minusButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
String w2 = Wert2.getText();
w1.trim();
w2.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
double dw2 = Double.valueOf(w2).doubleValue();
Ausgabe.setText("" + (dw1 - dw2));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void malButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
String w2 = Wert2.getText();
w1.trim();
w2.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
double dw2 = Double.valueOf(w2).doubleValue();
Ausgabe.setText("" + (dw2 * dw1));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void divButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
String w2 = Wert2.getText();
w1.trim();
w2.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
double dw2 = Double.valueOf(w2).doubleValue();
Ausgabe.setText("" + (dw1 / dw2));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void ExButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
String w2 = Wert2.getText();
w1.trim();
w2.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
double dw2 = Double.valueOf(w2).doubleValue();
Ausgabe.setText("" + (Math.pow(dw1, dw2)));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void exButton1_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
String w2 = Wert2.getText();
w1.trim();
w2.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
double dw2 = Double.valueOf(w2).doubleValue();
Ausgabe.setText("" + (Math.pow(dw2, (1 / dw1))));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void sinButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
w1.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
Ausgabe.setText("" + Math.sin(dw1));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void jButton1_ActionPerformed(ActionEvent evt) {
Wert1.setText(Ausgabe.getText());
}
public void EndeButton_ActionPerformed(ActionEvent evt) {
System.exit(0);
}
// EndeButton Methoden
public static void main(String[] args) {
new Taschenrechner("Taschenrechner");
}
public void cosButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
w1.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
Ausgabe.setText("" + Math.cos(dw1));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void Reset_ActionPerformed(ActionEvent evt) {
Ausgabe.setText("Ausgabe");
Wert1.setText("");
Wert2.setText("");
}
public void tanButton_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
w1.trim();
try {
double dw1 = Double.valueOf(w1).doubleValue();
Ausgabe.setText("" + Math.tan(dw1));
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void Zwischenablage_ActionPerformed(ActionEvent evt) {
String a = Ausgabe.getText();
this.copyToClipboard(a);
}
public void copyToClipboard(String a) {
Toolkit.getDefaultToolkit().getSystemClipboard()
.setContents(new StringSelection(a), null);
}
public void Vergrössern () {
setSize(Toolkit.getDefaultToolkit().getScreenSize());
}
public void Hinweise_ActionPerformed(ActionEvent evt) {
JFrame fenster = new JFrame("Hinweise");
fenster.pack();
fenster.setVisible(true);
//fenster.setLayout(
}
public void Random_ActionPerformed(ActionEvent evt) {
String w1 = Wert1.getText();
String w2 = Wert2.getText();
try {
int dw1 = Integer.valueOf(w1).intValue();
int dw2 = Integer.valueOf(w2).intValue();
Random random = new Random();
Integer a = random.nextInt(dw1 - dw2 + 1) + dw1;
String b = a.toString();
Ausgabe.setText(b);
} catch (NumberFormatException nfe) {
Ausgabe.setText("Keine gültige Zahl, du Idiot!");
}
}
public void Notiz_ActionPerformed(ActionEvent evt) {
}
public void Notizen_ActionPerformed(ActionEvent evt) {
try {
Runtime.getRuntime().exec("C:\\Programme\\UniversalLexikon2003\\Lexikon.exe"); //hier bin ich auch noch dabei
}
catch (Exception e) {
}
}
}
// Ende Methoden
Das ist der Code für einen primitiven Taschenrechner. Ich weiß manche Klassen werden gar nicht aufgerufen ist aber noch in Entwicklung.
Mfg
Janosch