Why are threads being created for each component in a GUI program?

I was making a multithreaded gui program and noticed unexpected (at least I never expected this) behavior. Apparently a new thread is created for each new graphical component created. Here is some code and output to demonstrate:

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

publicclass gui

{

publicstaticvoid main(String[] args)

{

System.out.println("thread count at beginning of main: " +Thread.activeCount());

JButton create_button =new JButton("Create!");

JButton about_button =new JButton("About...");

JButton quit_button =new JButton("Quit");

System.out.println("thread count after making 3 buttons: " +Thread.activeCount());

Frame frame =new JFrame();

System.out.println("thread count after constructing JFrame: " +Thread.activeCount());

frame.setSize(100,100);

frame.setVisible(true);

System.out.println("thread count after making JFrame visible: " +Thread.activeCount());

System.out.println("thread count at end of main: " +Thread.activeCount());

}

}

and the output from that code is this:

thread count at beginning of main: 1

thread count after making 3 buttons: 4

thread count after constructing JFrame: 4

thread count after making JFrame visible: 5

thread count at end of main: 5

So I was wondering if anyone could explain why new threads are created, or give me a link to a site where I could learn more about this phenomena. (Also this is my first attempt to distribute duke dollars)

[2326 byte] By [ericodea] at [2007-11-26 15:09:51]
# 1
It's got nothing to do with the number of GUI elements, there are a few service threads running. Btw, I get 1-3-3-4-4 as output.Hint: hit Ctrl+Break when focussed on the DOS prompt to see what threads are running.
quittea at 2007-7-8 9:00:34 > top of Java-index,Java Essentials,Java Programming...