Witam Chcę napisać program który gdy na Labe(JLabel) Wypisze się tekst Gotowe ma zrobić określoną rzecz ale ten teks zostanie wyświetlony gdy do Field(JTextField) Wpisz się odpowiedni tekst i tu jest problem ponieważ on sprawdza czy to jest tam wypisane Od razu bo włączeniu programu raz i później już nie Zamieszczam kod programu
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Tak {
public static void main(String[] args) {
Ramka ramka = new Ramka();
ramka.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ramka.show();
JOptionPane.showMessageDialog(ramka,"Witam w Programie");
}
}
class Ramka extends JFrame
{
private static final int SZEROKOSC = 400;
private static final int WYSOKOSC = 300;
public Ramka()
{
JPanel Panel = new JPanel();
final JLabel Labe2 = new JLabel("");
final JLabel Labe = new JLabel("Początek Matha");
final JTextField Field = new JTextField("Tu Wpisz hasło");
Panel.add(Field,BorderLayout.NORTH);
Panel.add( Labe,BorderLayout.SOUTH);
Panel.add(Labe2);
Container powZawartosci = getContentPane();
powZawartosci.add(Panel,BorderLayout.CENTER);
JMenuBar bar = new JMenuBar();
JMenu Plik = new JMenu("Plik");
JMenuItem Wybor = new JMenuItem("Wybór pliku");
Labe2.setVisible(false);
Plik.add(Wybor);
bar.add(Plik);
setJMenuBar(bar);
setSize(WYSOKOSC ,SZEROKOSC);
meto metok = new meto(Labe.getText() );
Field.addKeyListener(new java.awt.event.KeyAdapter(){
public void keyReleased(KeyEvent evt)
{
metoda( Field.getText());
}
void metoda ( String txt){ if(txt.equals("1234567890")){
Labe.setText("Gotowe");
}};
});}}
class meto
{
public meto(String string)
{
JLabel Labe3 = new JLabel("a");
JPanel p = new JPanel();
p.add(Labe3);
if(string.equals("Gotowe"))
{
System.out.println(Labe3);
}
}}
Dzięki z góry za pomoc. A i po tym Jeszcze bd wykonywane inne akcje dlatego kod taki dziwny :)