Hallo Java-Forum,
das nächste Problem ist wieder bei mir da. Und zwar habe ich jetzt das Problem das ich in meiner jComboBox meine drei Sachen drin habe die ich zur Auswahl haben möchte. Doch wie mache ich das jetzt das wenn ich jetzt z.B "Kamera" auswähle und dann auf "Öffnen" Drücke er mir in die Methode Kamera Springt und mir somit meine Bat Datei Öffnet?
Hier ist der Code Sry wenn ich so blöd frage habe aber wirklich keine Ahnung davon :§
Vielen Dank jetzt schon mal :=)
das nächste Problem ist wieder bei mir da. Und zwar habe ich jetzt das Problem das ich in meiner jComboBox meine drei Sachen drin habe die ich zur Auswahl haben möchte. Doch wie mache ich das jetzt das wenn ich jetzt z.B "Kamera" auswähle und dann auf "Öffnen" Drücke er mir in die Methode Kamera Springt und mir somit meine Bat Datei Öffnet?
Hier ist der Code Sry wenn ich so blöd frage habe aber wirklich keine Ahnung davon :§
Java:
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import javax.swing.*;
import javax.swing.event.*;
/**
*
* Beschreibung
*
* @version 1.0 vom 17.04.2015
* @author
*/
public class RemoteTool extends Frame {
// Anfang Attribute
private JComboBox jComboBox1 = new JComboBox();
private DefaultComboBoxModel jComboBox1Model = new DefaultComboBoxModel();
private JButton jButton1 = new JButton();
private JLabel jLabel1 = new JLabel();
// Ende Attribute
public RemoteTool(String title) {
// Frame-Initialisierung
super(title);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) { dispose(); }
});
int frameWidth = 310;
int frameHeight = 218;
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);
Panel cp = new Panel(null);
add(cp);
// Anfang Komponenten
jComboBox1.setModel(jComboBox1Model);
jComboBox1.setBounds(24, 56, 241, 41);
jComboBox1Model.addElement("Kamera");
jComboBox1Model.addElement("Haussteuerung");
jComboBox1Model.addElement("Kios");
cp.add(jComboBox1);
jButton1.setBounds(56, 112, 177, 49);
jButton1.setText("Öffnen ");
jButton1.setMargin(new Insets(2, 2, 2, 2));
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
jButton1.setFont(new Font("Dialog", Font.BOLD, 16));
cp.add(jButton1);
jLabel1.setBounds(8, 16, 276, 25);
jLabel1.setText("Wählen Sie einen Raspberry Pi aus:");
jLabel1.setFont(new Font("Dialog", Font.BOLD, 16));
cp.add(jLabel1);
// Ende Komponenten
setVisible(true);
} // end of public RemoteTool
// Anfang Methoden
public static void main(String[] args) {
new RemoteTool("RemoteTool");
} // end of main
public void jButton1_ActionPerformed(ActionEvent evt) {
//Button Methode
}
//Die Methoden für die einzelnen Pi's
public void Kamera(){
try {
System.out.println( Runtime.getRuntime().exec("D:/Users/Steffen/Desktop/Remote Tool/Bat Dateien/kamera.bat"));
} catch (IOException e) {
e.printStackTrace();
}
}
public void Haussteuerung(){
try {
System.out.println( Runtime.getRuntime().exec("D:/Users/Steffen/Desktop/Remote Tool/Bat Dateien/haussteuerung.bat"));
} catch (IOException e) {
e.printStackTrace();
}
}
public void Kios(){
try {
System.out.println( Runtime.getRuntime().exec("D:/Users/Steffen/Desktop/Remote Tool/Bat Dateien/kios.bat"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
Vielen Dank jetzt schon mal :=)