0

I'm making a Server with a database inside, but while I'm loading the main JFrame and while I'm connecting to the database reading username & password from a .properties file I chosed to let the user know that the program is running, what the program is doing in that specific moment, and also let him create a .properties file if it not exists (first launch). The problem is that I need to create 2 jframes, 1 that shows the launch progress, and 1 that appears only when user needs to create a .properties file: the problem is that I have to pause the first one while the second is running, and restart running the first while the second is closed performing all actions; I made it in two ways, but it didn't work: first, I tried inserting a wait() call opening the second JFrame and a notify() call while closing it; second, I tried using threads, but the problem is that the thread that I stop doesn't start when it should... here's some code:

jFrame1.setBounds(0,0,500,500);
    this.setVisible(true);
    jProgressBar2.setValue(0);
    prop = new Properties();
    jTextArea1.setText(jTextArea1.getText()+"Searching file config.properties... \n");
    try {
        FileReader fr = new FileReader("config.properties");
        jProgressBar2.setValue(33);
        jLabel3.setText("33");
        jTextArea1.setText(jTextArea1.getText()+"File config.properties found... \n");
    } catch (FileNotFoundException ex) {
        jFrame1.setVisible(true);
        jTextArea1.setText(jTextArea1.getText()+"File config.properties not found... \n");
    }

I want to pause while I ented the "catch" section; "this" is the first JFrame, "jFrame1" is the second one. Some hints/tips?

4

1 回答 1

5

Solution: don't use multiple JFrames. Make the window that's acting as a modal dialog not a second JFrame, but rather a real modal JDialog.

We should probably close this question as a duplicate as this exact same question gets asked again and again.

于 2013-05-03T21:42:29.303 回答