public class Chap extends Frame implements ActionListener
{
private Button keys[];
private Panel keypad;
private Panel fields;
private TextField nameField;
private TextField numberField;
private String name;
private int number;
private boolean clearText;
private boolean foundKey;
Button enterButton = new Button("Enter");
Button clearButton = new Button("Clear");
Button printButton = new Button("Print");
String names, numbers;
String ArrayValues[][] = new String[10][2];
public Chap()
{
enterButton.addActionListener(this);
clearButton.addActionListener(this);
printButton.addActionListener(this);
enterButton.setActionCommand("Enter");
clearButton.setActionCommand("Clear");
printButton.setActionCommand("Print");
// construct components and initialize beginning values
nameField = new TextField(20);
numberField = new TextField(20);
nameField.setEditable(true);
numberField.setEditable(false);
keypad = new Panel();
fields = new Panel();
keys = new Button[10];
number = 0;
name = "";
clearText = true;
fields.add(nameField);
fields.add(numberField);
fields.add(enterButton);
fields.add(clearButton);
fields.add(printButton);
public void actionPerformed(ActionEvent e)
{
if(arg == "About")
{
String message = "Program";
JOptionPane.showMessageDialog(null,message,"About Program",JOptionPane.INFORMATION_MESSAGE);
}
if(arg == "Enter")
{
for (int counter = 0; counter < 10; counter ++)
{
}
}
if(arg == "Print")
{
JOptionPane.showMessageDialog(null,ArrayValues,"Info",JOptionPane.INFORMATION_MESSAGE);
}
私は、最大10の電話番号と名前を格納するプログラムを作成する必要があります。ユーザーが印刷をクリックすると、格納されたすべてのデータが表示されます。私はどのように配列にデータを格納するのか分からない。名前欄には、番号フィールドは、テンキーを通じて入力する情報を格納し、後でその情報を出力する配列を作成するにはどうすればよいですか?
投稿したすべてのコードにあなたの質問はどのように関連していますか?問題の再現や説明に必要な最小限のコードを追加してください。 – Savior
@pillar問題を解決するために何が必要なのかよく分かりませんでした。 – Jodie
次に、研究にもっと時間を要するでしょう。あなたの次の質問:http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java – Savior