アプリケーションをスタンドアロン (JFrame) からアプレット (JApplet) に変換しています。FileDialog コンストラクターのパラメーターを親フレームから getContentPane に変更しましたが、うまくいきません。Jpanel を Frame にキャストできないという Class Cast 例外が発生しました。
SSCCEを見つけてください。この問題を理解するのを手伝ってください。
public class SampleApplet extends JApplet{
protected JButton countryButton = new JButton("Select");
public synchronized void init()
{
this.setBounds(new Rectangle(350,350));
this.add(countryButton);
countryButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
getCountries();
getCountries();
}
});
}
protected void getCountries() {
FileDialog fileDialog_ImageIn = new FileDialog((Frame) getContentPane() ,"Select a GIF file", FileDialog.LOAD);
fileDialog_ImageIn.setVisible(true);
if (fileDialog_ImageIn.getFile() == null)
return;
else
System.out.println(fileDialog_ImageIn.getDirectory() + fileDialog_ImageIn.getFile());
}
}