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個
どこが間違っているのでしょうか。
どなたか教えてください。
出来たら修正お願いします。
No.1ベストアンサー
- 回答日時:
意味をわからずかいているから、エラーの原因がわからない。
Layoutて何?
そんなクラスあるいはインターフェースは標準apiで見たことがないのだが。
しかも、コードの中でも使っていないようだが。
何のために書いた?
あとは、ActionEventがimportされていない。
この2つで、3つのエラーは解決するはず。
No.2
- 回答日時:
>分らないから聞いてるんですけど。
何に対して?
だいたい君は言葉が足りなすぎると思うけど。
質問文からは
「どこが間違えているかわからない」
としかいっていないよね?
「プログラムコードがわからない」
とは言っていないよね?
このコードは自分で書いたんじゃないの?
だから、
「Layoutてどういう意図で書いた?」
と聞いたわけだが。
特に意味なく書いたのであれば、
そのimport文は削除してしまったほうがよい。
一応完成したんですけど何故か「グー」は表示されず
ただ「パー」「チョキ」を選択したらその画像が表示されず
じゃんけんにはならない状態なんですがどうしたら良いですか。
分らなくなったんで教えて頂けませんか。
もう一つの質問に現在のプログラムを書いたんでそちらを見て貰えませんか。出来たら修正して頂けませんか。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・14歳の自分に衝撃の事実を告げてください
- ・架空の映画のネタバレレビュー
- ・「お昼の放送」の思い出
- ・昨日見た夢を教えて下さい
- ・ちょっと先の未来クイズ第4問
- ・【大喜利】【投稿~10/21(月)】買ったばかりの自転車を分解してひと言
- ・メモのコツを教えてください!
- ・CDの保有枚数を教えてください
- ・ホテルを選ぶとき、これだけは譲れない条件TOP3は?
- ・家・車以外で、人生で一番奮発した買い物
- ・人生最悪の忘れ物
- ・【コナン30周年】嘘でしょ!?と思った○○周年を教えて【ハルヒ20周年】
- ・ハマっている「お菓子」を教えて!
- ・最近、いつ泣きましたか?
- ・夏が終わったと感じる瞬間って、どんな時?
- ・10秒目をつむったら…
- ・人生のプチ美学を教えてください!!
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・都道府県穴埋めゲーム
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
eclipseに記述したjavaファイル...
-
(急募)JavaカレンダーをGUI可に...
-
Activityクラスの取得方法
-
JWindowにコンポーネントは載せ...
-
java初心者です。座標取得と図...
-
JAXPのDTD検証
-
javaで正規表現ができません
-
LDAPのコネクションが切れません
-
setAttribute(String, int)は適...
-
javaでスタート画面を作ってい...
-
Javaを使ってデジタル時計を作...
-
シャットダウンフックが呼ばれない
-
javaプログラムの問題です
-
Selenium IDEでexportしたコー...
-
透過GIFの判定の仕方ありますか?
-
JTextAreaのサイズについて
-
importするには java.io.*; imp...
-
文字列を次々に表示するアプリ...
-
「例外 *** は対応する try 文...
-
androidアプリが強制終了してし...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
eclipseに記述したjavaファイル...
-
importするには java.io.*; imp...
-
<forEach> 内で供給された "ite...
-
「例外 *** は対応する try 文...
-
java.util.Comparatorのcompare...
-
ColabでのPytorchのエラー
-
正規表現について
-
JAVAサーブレット。 HTML...
-
ActionForm form にnullが入っ...
-
Selenium IDEでexportしたコー...
-
ファイル名を動的に生成したい
-
【java】検索フォームの検索結...
-
setAttribute(String, int)は適...
-
シャットダウンフックが呼ばれない
-
do while文のエラー??
-
JPEG画像のみを印刷したいので...
-
サーバーAからサーバーBへPOST...
-
メニューバーのプログラム
-
アプレットを実行すると、×が表...
-
JOGLのインストール方法
おすすめ情報