やあみんな私は本当にのJavaのグラフィック部分で練習を始めた、と私は私が今まで見たことがないているエラーになってきた。私は例外「AWT-EventQueueの-0サポートされていない操作
を私のコードを投稿するつもりで、エラーメッセージの画像が表示されるのは、実際に何が起こっているのかがほとんど分かっていないからです。アイデアはありますが、混乱しないようにしてください。
いずれかのボタンをクリックしようとするとこのエラーがスローされます。エラーメッセージ行は、コード
に含まれているオーバーライド方法の行番号を参照しています。2つのボタンのいずれかをクリックしようとしたとき、私はプログラム それはエラー(上の画像)をスローし、エラーを実行した後、オーバーライドメソッドは、自動生成され
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
*
* @author Jonathan
*/
class WindowDestroyer extends WindowAdapter
{
public void window(WindowEvent e)
{
System.exit(0);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package game;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Set;
/**
*
* @author Jonathan
*/
public class ButtonDemo extends JFrame implements ActionListener
{
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
public ButtonDemo()
{
setSize(WIDTH, HEIGHT);
WindowDestroyer listener = new WindowDestroyer();
addWindowListener(listener);
Container contentPane = getContentPane();
contentPane.setBackground(Color.white);
contentPane.setLayout(new FlowLayout());
JButton sunnyButton = new JButton("Sunny");
sunnyButton.addActionListener(this);
contentPane.add(sunnyButton);
JButton cloudyButton = new JButton("Cloudy");
cloudyButton.addActionListener(this);
contentPane.add(cloudyButton);
}
public void actionPreformed(ActionEvent e)
{
String actionCommand = e.getActionCommand();
Container contentPane = getContentPane();
if(actionCommand.equals("Sunny"))
contentPane.setBackground(Color.BLUE);
else if(actionCommand.equals("Cloudy"))
contentPane.setBackground(Color.GRAY);
else
System.out.println("Error in button interface");
}
@Override
public void actionPerformed(ActionEvent ae) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
質問を更新し、より良いタイトルを設定してください – Dekel
'actionPerformed'メソッドを見てください。*" throw new UnsupportedOperationException( "まだサポートされていません。"); "* - これは問題です – MadProgrammer
私はそれをサポートしていないのですか? –