Theblazomatic2:
私はGUIのを構築するためにビデオを追っていると私は練習のためのビデオのコードを使用し、しかし、ビデオはそれが今2020年である2009年からです。
ビデオは、参考のためにあなたがそれを調べることができ、ユーチューブ上にあります。
https://www.youtube.com/watch?v=qhYook53olE
私が抱えている問題は、エラーをスローthehandlerクラスプライベートです。
それは言う:GUI.thehandlerが継承された抽象メソッドを実装する必要がありますActionListener.actionPerformed(のActionEvent)
ビデオでコードが細かい、それが終了したとき、それは現在の方法を実行します。
これはもはや多分動作するように言語が更新されなかったのですか?
すべてのヘルプは大歓迎です。
package GUI;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import java.util.Scanner;
public class GUI extends JFrame{
private JTextField item1;
private JTextField item2;
private JTextField item3;
private JPasswordField passwordField;
public GUI() {
super("Find The King");
setLayout(new FlowLayout());
item1 = new JTextField(10);
add(item1);
item2 = new JTextField("Enter text here.");
add(item2);
item3 = new JTextField("uneditable",20);
item3.setEditable(false);
add(item3);
passwordField = new JPasswordField("Mypass");
add(passwordField);
thehandler handler = new thehandler();
item1.addActionListener(handler);
item2.addActionListener(handler);
item3.addActionListener(handler);
passwordField.addActionListener(handler);
}
private class thehandler implements ActionListener{
public void actionpPerformed(ActionEvent event) {
String string = "";
if (event.getSource()==item1)
string=String.format("field 1 : %s", event.getActionCommand());
else if (event.getSource()==item1)
string=String.format("field 1 : %s", event.getActionCommand());
else if (event.getSource()==item2)
string=String.format("field 2 : %s", event.getActionCommand());
else if (event.getSource()==item3)
string=String.format("field 3 : %s", event.getActionCommand());
string=String.format("password field is : %s", event.getActionCommand());
}
}
}
DM:
クラスは次のようになります。
private class thehandler implements ActionListener{
public void actionPerformed(ActionEvent event) {
String string = "";
if (event.getSource()==item1)
string=String.format("field 1 : %s", event.getActionCommand());
else if (event.getSource()==item1)
string=String.format("field 1 : %s", event.getActionCommand());
else if (event.getSource()==item2)
string=String.format("field 2 : %s", event.getActionCommand());
else if (event.getSource()==item3)
string=String.format("field 3 : %s", event.getActionCommand());
string=String.format("password field is : %s", event.getActionCommand());
}
あなたがから実装したいというインタフェースを持っている場合は、一部の命令に従わなければなりません。一つは、そのインターフェイスにmendatoryあるメソッドを実装することです。specifc署名を与えられている必要な方法、彼らは非常に特定の名前と非常に特定の番号とパラメータの配列を有してしなければならないことを意味..手段
actionPerformed(ActionEvent event, String aString) {
...
}
あまりにも、間違っているだろう