Ich habe zu ersten mal ein Programm in eine Jar File kompiliert aber es zeigt mir folgende Fehlermeldung an: Invalid or corrupted Files
hier der code
hier der code
Java:
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import java.awt.Color;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import java.awt.Button;
import java.awt.Label;
import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.LinkedList;
import java.awt.event.ActionEvent;
import java.awt.Font;
public class Display extends JFrame{
private static JTextField newInhabitantTextField;
private static JTextField newClubTextField;
private static JTextField newOrganisationTextField;
private static JTextField searchTextField;
static Collection<String> inhabitantsData = new LinkedList<String>();
static Collection<String> clubData = new LinkedList<String>();
static Collection<String> organisationsData = new LinkedList<String>();
private static JButton addInhabitantButton;
private static JButton addClubButton;
private static JButton addOrganisation;
private static JButton btnOk;
/**
* Create the panel.
*/
public Display() {
getContentPane().setLayout(null);
this.setVisible(true);
JLabel lblVillageOrganizer = new JLabel("Village organizer");
lblVillageOrganizer.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblVillageOrganizer.setForeground(Color.RED);
lblVillageOrganizer.setBounds(165, 3, 123, 20);
getContentPane().add(lblVillageOrganizer);
//Methoden_____________________________________________________________________________________________________
//Labels________________________________________________________________________________________
JLabel lblNewInhabitent = new JLabel("New inhabitant");
lblNewInhabitent.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblNewInhabitent.setBounds(30, 30, 86, 14);
getContentPane().add(lblNewInhabitent);
JLabel lblNewLabel = new JLabel("New club");
lblNewLabel.setForeground(Color.BLUE);
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblNewLabel.setBounds(185, 30, 100, 14);
getContentPane().add(lblNewLabel);
JLabel lblNewOrganisation = new JLabel("New organisation");
lblNewOrganisation.setForeground(Color.BLUE);
lblNewOrganisation.setFont(new Font("Tahoma", Font.PLAIN, 13));
lblNewOrganisation.setBounds(337, 30, 100, 14);
getContentPane().add(lblNewOrganisation);
JLabel lblSearchInhabitent = new JLabel("Search : ");
lblSearchInhabitent.setForeground(Color.BLUE);
lblSearchInhabitent.setBounds(10, 205, 86, 14);
getContentPane().add(lblSearchInhabitent);
JLabel lblChooseWhatYou = new JLabel("Choose what you want to search");
lblChooseWhatYou.setBounds(152, 144, 285, 14);
getContentPane().add(lblChooseWhatYou);
JLabel label = new JLabel("");
label.setBounds(217, 316, 46, 14);
getContentPane().add(label);
//Textfield_____________________________________________________
newInhabitantTextField = new JTextField();
newInhabitantTextField.setBounds(10, 55, 123, 20);
getContentPane().add(newInhabitantTextField);
newInhabitantTextField.setColumns(10);
newClubTextField = new JTextField();
newClubTextField.setBounds(143, 55, 163, 20);
getContentPane().add(newClubTextField);
newClubTextField.setColumns(10);
newOrganisationTextField = new JTextField();
newOrganisationTextField.setBounds(316, 55, 143, 20);
getContentPane().add(newOrganisationTextField);
newOrganisationTextField.setColumns(10);
searchTextField = new JTextField();
searchTextField.setBounds(68, 202, 390, 20);
getContentPane().add(searchTextField);
searchTextField.setColumns(10);
// Listener_______________________________________________________________________________________________
JButton addInhabitantButton = new JButton("Add inhabitant");
addInhabitantButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
inhabitantsData.add(newInhabitantTextField.getText());
JOptionPane.showMessageDialog(null, newInhabitantTextField.getText() + "wurde der Datenbank hinzugefügt", newInhabitantTextField.getText() + "wurde der Datenbank hinzugefügt" , JOptionPane.INFORMATION_MESSAGE);
newInhabitantTextField.setText("");
getContentPane().repaint();
}
});
addInhabitantButton.setBounds(10, 86, 123, 23);
getContentPane().add(addInhabitantButton);
JButton addClubButton = new JButton("Add club");
addClubButton.setBounds(143, 86, 163, 23);
getContentPane().add(addClubButton);
addClubButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
clubData.add(newClubTextField.getText());
JOptionPane.showMessageDialog(null, newClubTextField.getText() + " wurde der Datenbank hinzugefügt", newClubTextField.getText() + " wurde der Datenbank hinzugefügt" , JOptionPane.INFORMATION_MESSAGE );
newClubTextField.setText("");
}
});
JButton addOrganisationButton = new JButton("Add organisation");
addOrganisationButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
organisationsData.add(newOrganisationTextField.getText());
JOptionPane.showMessageDialog(null, newOrganisationTextField.getText() + " wurde der Datenbank hinzugefügt", newOrganisationTextField.getText() + " wurde der Datenbank hinzugefügt" , JOptionPane.INFORMATION_MESSAGE );
newOrganisationTextField.setText(" ");
}
});
addOrganisationButton.setBounds(316, 86, 143, 23);
getContentPane().add(addOrganisationButton);
JButton btnOk = new JButton("O.K.");
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
searchTextField.getText();
if(inhabitantsData.contains(searchTextField.getText())) {
JOptionPane.showMessageDialog(null, searchTextField.getText() + " wurde in der Datenbank gefunden" + JOptionPane.INFORMATION_MESSAGE );
searchTextField.setText(" ");
}
else {
JOptionPane.showMessageDialog(null, searchTextField.getText()+ " wurde nicht gefunden");
searchTextField.setText(" ");
}
if(clubData.contains(searchTextField.getText())) {
JOptionPane.showMessageDialog(null, searchTextField.getText() + " wurde in der Datenbank gefunden");
searchTextField.setText(" ");
}
else {
JOptionPane.showMessageDialog(null, searchTextField.getText()+ " wurde nicht gefunden");
searchTextField.setText(" ");
}
if(organisationsData.contains(searchTextField.getText())) {
JOptionPane.showMessageDialog(null, searchTextField.getText() + " wurde in der Datenbank gefunden" );
searchTextField.setText(" ");
}
else {
JOptionPane.showMessageDialog(null, searchTextField.getText()+ " wurde nicht gefunden");
searchTextField.setText(" ");
}
}
});
btnOk.setBounds(185, 248, 89, 23);
getContentPane().add(btnOk);
}
//________________Main_______________________________________
public static void main( String [] args) {
Display display = new Display ();
display.setSize(500,400);
}
}