Any matter that has a temperature higher than its surroundings emits radiation at various frequencies. The total amount of radiation and the distribution of the emitted wavelengths depend almost entirely on the temperature of the body and are not characteristics of the material itself. For an idealised black body that absorbs all radiation that falls onto it, this relationship between temperature and wavelength of maximum emission is completely precise. Many astronomical bodies, such as stars, can be considered to be almost perfect black bodies, so we can apply all the characteristics of a black body to them. Let's have a look at the radiation of black bodies at different temperatures:
We can see examples of the spectrum of emitted radiation for seven bodies at different temperatures, ranging from 100 degrees Kelvin to 10000 degrees Kelvin. Please note that this diagram is logarithmic. That means that the difference from one scale point to the next along each axis is a factor of 10! The range of visible light is indicated with the colours of the rainbow between 0.4 and 0.8 µm.
There are two important things to notice:
F = σ x T4
with F being the radiation flux in W/m2, σ being a physical constant, the so called Stefan-Bolzmann Constant, and T being the temperature of the object. Note that the flux increases with the fourth power of the temperature. A body with a surface temperature of 2000 degrees Kelvin radiates 16 times more energy than a body with a temperature of 1000 degrees Kelvin.A red dwarf with a surface temperature of 3000 K emits much more light towards the red end of the visible spectrum, hence it appears red. The hot stars appear blue since they emit a bigger part of their radiation in blue than they do in red. Technically they have their peak radiation in the ultraviolet wavelengths that humans can't detect. And since in addition our eyes are not very good at detecting a violet colour (the shortest wavelength we can see) these stars appear blue to us.
It is important to understand the exact radiation pattern of celestial bodies and then scan the sky at all wavelengths. This way we can detect bodies within a wide range of temperatures. A brown dwarf for example has a temperature of 1000 degrees Kelvin and can best be observed in the infrared at about 3 µm; at wavelengths of visible light its radiation is about 100 000 to one million times weaker.