ホテルを選ぶとき、これだけは譲れない条件TOP3は?

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import java.awt.Container;
import java.awt.BorderLayout;
import javax.swing.ImageIcon;
import java.applet.*;
import java.awt.image.BufferedImage;
import javax.swing.ButtonGroup;
import java.util.Scanner;
import java.util.Random;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.imageio.ImageIO;

import java.awt.event.ActionListener;
import javax.swing.JButton;
import java.awt.GridLayout;
import javax.swing.Layout;
import javax.swing.JLabel;

public class Janken_04 extends JFrame implements ActionListener {
JPanel mainPanel, aitePanel;
JRadioButton GuButton, TyokiButton, PaButton;
ButtonGroup aiteGroup;
JButton setTeButton;
JLabel labe;
ImageIcon guImageIcon, tyokiImageIcon, paImageIcon;

public Janken_04() {
setSize(500, 400);
setLocationRelativeTo(null);
setLayout(new BorderLayout());

setPanel();
setAitePanel();
setImage();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

private void setImage() {
guImageIcon = new ImageIcon("guu_01.png");
tyokiImageIcon = new ImageIcon("cyoki_01.png");
paImageIcon = new ImageIcon("pa01.png");
}

private void setPanel() {
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
add(mainPanel, BorderLayout.CENTER);
labe = new JLabel();
mainPanel.add(labe, BorderLayout.CENTER);

setTeButton = new JButton("手を出す");
setTeButton.addActionListener(this);
add(setTeButton, BorderLayout.SOUTH);
}

private void setAitePanel() {
aitePanel = new JPanel();
aitePanel.setLayout(new GridLayout(1, 3));
add(aitePanel, BorderLayout.NORTH);

GuButton = new JRadioButton("グー");
TyokiButton = new JRadioButton("チョキ");
PaButton = new JRadioButton("パー");

aiteGroup = new ButtonGroup();
aiteGroup.add(GuButton);
aiteGroup.add(TyokiButton);
aiteGroup.add(PaButton);
aitePanel.add(GuButton);
aitePanel.add(TyokiButton);
aitePanel.add(PaButton);
}

@Override
public void actionPerformed(ActionEvent e) {
if(GuButton.isSelected()) {

}else if(PaButton.isSelected()) {
labe.setIcon(paImageIcon);

}else if(TyokiButton.isSelected()) {
labe.setIcon(tyokiImageIcon);
}
}

public static void main(String[] args) {
new Janken_04();
}
}
といった感じで作成したのですが下記のエラーが発生しました。
C:\java>javac Janken_04.java
Janken_04.java:19: エラー: シンボルを見つけられません
import javax.swing.Layout;
^
シンボル: クラス Layout
場所: パッケージ javax.swing
Janken_04.java:81: エラー: シンボルを見つけられません
public void actionPerformed(ActionEvent e) {
^
シンボル: クラス ActionEvent
場所: クラス Janken_04
エラー2個
どこが間違っているのでしょうか。
どなたか教えてください。
出来たら修正お願いします。

A 回答 (2件)

意味をわからずかいているから、エラーの原因がわからない。



Layoutて何?
そんなクラスあるいはインターフェースは標準apiで見たことがないのだが。
しかも、コードの中でも使っていないようだが。
何のために書いた?


あとは、ActionEventがimportされていない。


この2つで、3つのエラーは解決するはず。
    • good
    • 1
この回答へのお礼

分らないから聞いてるんですけど。
(質問)

お礼日時:2015/09/25 09:51

>分らないから聞いてるんですけど。


何に対して?

だいたい君は言葉が足りなすぎると思うけど。

質問文からは
「どこが間違えているかわからない」
としかいっていないよね?

「プログラムコードがわからない」
とは言っていないよね?

このコードは自分で書いたんじゃないの?

だから、
「Layoutてどういう意図で書いた?」
と聞いたわけだが。

特に意味なく書いたのであれば、
そのimport文は削除してしまったほうがよい。
    • good
    • 1
この回答へのお礼

一応完成したんですけど何故か「グー」は表示されず
ただ「パー」「チョキ」を選択したらその画像が表示されず
じゃんけんにはならない状態なんですがどうしたら良いですか。
分らなくなったんで教えて頂けませんか。
もう一つの質問に現在のプログラムを書いたんでそちらを見て貰えませんか。出来たら修正して頂けませんか。

お礼日時:2015/09/25 10:22

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!