После choose.setVisible(true)
Я хотел бы сначала , чтобы иметь возможность выбирать и после нажатия кнопки ok , чтобы продолжить выполнение. Приведенный ниже код показывает chooser
и continues
не дожидаясь.Выполнение стоп-кода до нажатия кнопки
static class box extends JFrame {
Checkbox cboxtps = new Checkbox("Grf1", false);
Checkbox cboxrspt = new Checkbox("Grf2", false);
JLabel lblQts = new JLabel("Please select graphs");
JButton btn1 = new JButton("Go");
public box(String str) {
super(str);
setLayout(new GridLayout(4, 1));
add(lblQts);
add(cboxtps);
add(cboxrspt);
add(btn1);
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
System.out.println("You clicked the button");
}
});
}
}
public static void main(String args[]) {
box choose = new box("Select Graphs");
choose.setSize(300, 150);
choose.pack();
choose.setVisible(true);
List<File> filepaths = fileselect();
list = Splitter(filepaths);
}
JFrames не являются модными. Смотрите: http://stackoverflow.com/questions/1481405/how-to-make-a-jframe-modal-in-swing-java – theINtoy
Спасибо за это! Тогда я буду использовать JDialog! –