Leider funktioniert das nicht. Aber Danke für die Mühe! Ich schreib dir hier mal den ganzen Code rein, falls dir das weiterhilft. Ich kann dir auch gern nen Bild von dem Fenster schicken wenn du möchtest, also falls das hilft.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
/**
*
* Beschreibung
*
* @version 1.0 vom 14.11.2014
* @author
*/
public class PokeDex extends JFrame {
// Anfang Attribute
private JLabel jLabel1 = new JLabel();
private JLabel jLabel2 = new JLabel();
private JLabel jLabel3 = new JLabel();
private JTextField jTextField1 = new JTextField();
private JNumberField jNumberField1 = new JNumberField();
private JTextField jTextField2 = new JTextField();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
private JButton jButton3 = new JButton();
private JList jList1 = new JList();
private DefaultListModel jList1Model = new DefaultListModel();
private JScrollPane jList1ScrollPane = new JScrollPane(jList1);
private JLabel jLabel4 = new JLabel();
private ArrayList<String> pokemon = null;
int i;
public PokeDex() {
super();
pokemon = new ArrayList<String>();
pokemon.add("MissingNo");
pokemon.add("Bisasam");
pokemon.add("Bisaknosp");
pokemon.add("Bisaflor");
pokemon.add("Glumanda");
pokemon.add("Glutexo");
}
// Ende Attribute
public PokeDex(String title) {
// Frame-Initialisierung
super(title);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int frameWidth = 468;
int frameHeight = 460;
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
jLabel1.setBounds(32, 16, 123, 19);
jLabel1.setText("Name");
cp.add(jLabel1);
jLabel2.setBounds(32, 56, 123, 19);
jLabel2.setText("Nummer");
cp.add(jLabel2);
jLabel3.setBounds(32, 96, 123, 19);
jLabel3.setText("Typ");
cp.add(jLabel3);
jTextField1.setBounds(176, 16, 145, 25);
cp.add(jTextField1);
jNumberField1.setBounds(176, 56, 145, 25);
jNumberField1.setText("");
cp.add(jNumberField1);
jTextField2.setBounds(176, 96, 145, 25);
cp.add(jTextField2);
jButton1.setBounds(336, 16, 113, 25);
jButton1.setText("Suchen");
jButton1.setMargin(new Insets(2, 2, 2, 2));
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
cp.add(jButton1);
jButton2.setBounds(336, 56, 113, 25);
jButton2.setText("Suchen");
jButton2.setMargin(new Insets(2, 2, 2, 2));
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton2_ActionPerformed(evt);
}
});
cp.add(jButton2);
jButton3.setBounds(336, 96, 113, 25);
jButton3.setText("Zufallsbeitrag");
jButton3.setMargin(new Insets(2, 2, 2, 2));
jButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton3_ActionPerformed(evt);
}
});
cp.add(jButton3);
jList1.setModel(jList1Model);
jList1ScrollPane.setBounds(32, 144, 185, 193);
cp.add(jList1ScrollPane);
jLabel4.setBounds(240, 152, 211, 25);
jLabel4.setText("Suche dein Pokémon!");
cp.add(jLabel4);
// Ende Komponenten
setVisible(true);
} // end of public PokeDex
// Anfang Methoden
public void jButton1_ActionPerformed(ActionEvent evt) {
// TODO hier Quelltext einfügen
if (pokemon.contains(jTextField1.getText())) {
jLabel4.setText("Dieses Pokémon ist vorhanden.");
}else{
jLabel4.setText("Dieses Pokémon ist nicht vorhanden.");
}
}// end of jButton1_ActionPerformed
public void jButton2_ActionPerformed(ActionEvent evt) {
// TODO hier Quelltext einfügen
} // end of jButton2_ActionPerformed
public void jButton3_ActionPerformed(ActionEvent evt) {
// TODO hier Quelltext einfügen
} // end of jButton3_ActionPerformed
// Ende Methoden
public static void main(String[] args) {
new PokeDex("PokeDex");
} // end of main
} // end of class PokeDex
Alles anzeigen
Danke jedenfalls für deine Hilfe, hast mich auf jedenfall schon ein großes Stück weiter gebracht!