EventQueue?とは? 

サンプル

EventQueueExam.png
package com.snail.javaexam;

import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class EventQueueExam extends javax.swing.JFrame {

    /** Creates new form EventQueueExam */
    public EventQueueExam() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
      
      ※ GENERATED CODE ※
      
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                jTextArea1.setText(jTextArea1.getText() + "hello\n");
            }
        });
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new EventQueueExam().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration
}

EventQueue?の使い方

SwingUtility?.invokeLater() は、内部的に EventQueue?.invokeLater() を呼んでいる。同じ物。


Java#GUI


添付ファイル: fileEventQueueExam.png 2381件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2011-02-16 (水) 23:28:19 (4817d)
Short-URL:
ISBN10
ISBN13
9784061426061