I have a java program that dispays the temperature in digit format ie 87.7F. I would like to make a thermometer using graphics to do this. I have only been using java for 2 weeks now and just wonding if someone could give me pointers on the best way to accomplish this.

3 Years
Discussion Span
Last Post by JamesCherrill

make your class extend JFrame , then create a jpanel , that will be your own custom Contentpane , which you can add to the JFrame ,
then inside the contenpane , have two textfeilds , and a button in between them , 1st one takes in input , and on pressing the button , the output is shown on the 2nd text feild. and regarding the decimal point part , use a double instead of a an int.

this is a good place to get started with swing components.
if you have the head first java , book , i learned basic gui from there , found it quite helpful... maybe you can try that out too.

note : youll find the reason i suggested using your own jpanel contentpane within the first few pages of the link above. :) see if you can dig it out.

Edited by somjit{}


use JFreeCharts, there is termomether as pre_defined graph (in version that I tried), if not then is so easy to create Shapes with rainbows colors, toggle with value


that would be a good way to solve it. however , as OP says , in his 2ndweek only... maybe he should practise up some of the basic gui before going there.


First, let's assume you know some basic graphics stuff - how to create and display a window (if not you need to study a tutorial on that first).

Then look through this tutorial on custom painting in Swing for the basic info you will need.
Using that you can draw your thermometer as a rectangle whose length is defined by the temperature. You can decorate that with colors, text and numbers etc as you wish.

However, you may be able to get something close enough by using a simple JProgressBar

Votes + Comments
+1 for the JProgressBar idea.

hi friends can you tell me who we can make this software please help me for making this software please


Hello iqraw kaleem

There are people here who can help, but you must ask specific questions. Eg What software do you want to make? What do you know already? What exactly is stopping you from going further?

Please also note the DaniWeb Rules, including "Do not hijack old forum threads by posting a new question as a reply to an old one". Start a new thread for your question.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.