JTextArea не будет добавлять / setText - PullRequest
0 голосов
/ 07 марта 2012

Почему строка 17 не обновляется мгновенно? JFrame и JDialogs не представляют собой ничего особенного. Я хочу обновить textArea первого JDialog после удаления второго JDialog. Модальный JDialog вызывает метод dispose при нажатии на JButton.

package javaapplication1;

public class NewJFrame extends javax.swing.JFrame
{

public NewJFrame()
{
    initComponents();
    boolean isModal = true;
    NewJDialog jd = new NewJDialog(this, !isModal);
    jd.setVisible(true);
    jd.ta.setText("1\n"); //good
    NewJDialog1 d1 = new NewJDialog1(this,isModal);
    jd.ta.append("2\n"); //good
    d1.setVisible(true);
    System.out.println("3"); //prints at this instace
    jd.ta.append("3\n"); //doesn't display at this instance
    System.out.println("3"); //prints at this instace
    System.out.println(); //debug breakpoint                  
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 400, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 300, Short.MAX_VALUE)
    );

    pack();
}// </editor-fold>                        

public static void main(String args[])
{
    java.awt.EventQueue.invokeLater(new Runnable()
    {
        public void run()
        {
            new NewJFrame().setVisible(true);
        }
    });
}
// Variables declaration - do not modify                     
// End of variables declaration                   
}
...