比如:FileChooser aa=new JFileChooser();
int option=aa.showOpenDialog(this);//程序在这里就停下来,等待你的操作;
..................//上面只要操作不结束,这里的代码就不会被执行 现在我想实现在JFrame的main函数里面加载一个JPanel bb;在bb里面有2个按钮,一些文本框。
假设main()
{
this.add(bb);//这时候面板出来,我想程序想上面那样停下来等待,等待面板里面对按钮的操作
..............//这里的代码,我想在等上面的bb面板的操作结束才执行
}
请问怎么实现?谢谢了
int option=aa.showOpenDialog(this);//程序在这里就停下来,等待你的操作;
..................//上面只要操作不结束,这里的代码就不会被执行 现在我想实现在JFrame的main函数里面加载一个JPanel bb;在bb里面有2个按钮,一些文本框。
假设main()
{
this.add(bb);//这时候面板出来,我想程序想上面那样停下来等待,等待面板里面对按钮的操作
..............//这里的代码,我想在等上面的bb面板的操作结束才执行
}
请问怎么实现?谢谢了
import javax.swing.JFileChooser;public class openSourceAction
{
static final String newline = "\n"; public static void openDialog()
{
final int returnVal = doWithFrame.getFc().showOpenDialog(doWithFrame.getFrame()); if (returnVal == JFileChooser.CANCEL_OPTION)
{
return;
}
if(returnVal == JFileChooser.APPROVE_OPTION)
{
File file = null;
file = doWithFrame.getFc().getSelectedFile();
doWithFrame.getContent().append("打开目录: " + file.getAbsolutePath() + "." + newline);
contentContainer.setSrcDir(file.getAbsolutePath());
}
if(!contentContainer.getBookInfoProportey())
{
doWithFrame.getContent().append("读取目录的属性文件失败!" + newline);
}
else
{
doWithFrame.getSaveSourceButton().setEnabled(true);
// update.setEnabled(true);
doWithFrame.getProgressBar().setValue(0);
}
}
public static void openSave()
{
final int returnVal = doWithFrame.getFc().showOpenDialog(doWithFrame.getFrame()); if (returnVal == JFileChooser.CANCEL_OPTION)
{
return;
}
if (returnVal == JFileChooser.APPROVE_OPTION)
{
File file = null;
file = doWithFrame.getFc().getSelectedFile();
doWithFrame.getContent().append("您选择的保存目录: " + file.getAbsolutePath() + "." + newline);
contentContainer.setSaveDir(file.getAbsolutePath());
doWithFrame.getOpenButton().setEnabled(false);
doWithFrame.getUploadButton().setEnabled(true);
}
}}
个人认为你还是得学会看jdk文档,不然很难有所进步。
好好学习,天天向上。
{
//这里新起线程显示面板并负责唤醒此线程
this.add(bb);//这时候面板出来,我想程序想上面那样停下来等待,等待面板里面对按钮的操作
Thread.currentThread().interrupt();
..............//这里的代码,我想在等上面的bb面板的操作结束才执行
}