Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Thermometer Applet

Revelation1977
Revelation1977 


Write an applet that displays a thermometer. The user should be able to control the temperature with a slider component. When the user moves the slider, the thermometer should show the corresponding temperature. Attachments Tags
Clarifications

Answers

advance pay

sudheer488
sudheer488 



advance pay Attachments
Screenshots
Purchase Answer

Thermometer Applet

sudheer488
sudheer488 



Please find the code along with screenshots Attachments
Thermometer.rar (39 K) Download







Preview
the imported nbproject/build-impl.xml file. Another way to customize the build is by overriding existing main targets. The targets of interest are: -init-macrodef-javac: defines macro for javac compilation -init-macrodef-junit: defines macro for junit execution -init-macrodef-debug: defines macro for class debugging -init-macrodef-java:

Preview
HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (1.8.0_60)

Preview
--> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>All Classes</title> <meta name="date" content="2015-11-03"> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <script type="text/javascript" src="script.js"></script>

Preview
is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../package-summary.html">Package</a></li> <li><a href="../TempConverter.html" title="class in &lt;Unnamed&gt;">Class</a></li> <li

Preview
</script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li>Use</li> <li><a href="overview

Preview
href="package-summary.html">Package</a></li> <li>Class</li> <li>Use</li> <li><a href="overview-tree.html">Tree</a></li> <li class="navBarCell1Rev">Deprecated</li> <li><a href="index-files/index-1.html">Index</a></li> <li><a href="help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="index.html?deprecated-list.html" target="_top">Frames</a></li> <li><a href="deprecated-list.html" targ

Preview
section of the class description.</p> </li> <li class="blockList"> <h2>Constant Field Values</h2> <p>The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.</p> </li> </ul> <span class="emphasizedPhrase">This help file applies to API documentation generated using the standard doclet.</span></div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a

Preview
class <a href="../TempConverter.html" title="class in &lt;Unnamed&gt;">TempConverter</a></dt> <dd> <div class="block">This program creaates an instance of the TempConverter class, which displays a window with a slider.</div> </dd> </dl> <a href="index-1.html">M</a>&nbsp;<a href="index-2.html">T</a>&nbsp;</div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navig

Preview
class="navList"> <li><a href="../index.html?index-files/index-2.html" target="_top">Frames</a></li> <li><a href="index-2.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allCla

Preview
if (targetPage != "" && targetPage != "undefined") targetPage = targetPage.substring(1); if (targetPage.indexOf(":") != -1 || (targetPage != "" && !validURL(targetPage))) targetPage = "undefined"; function validURL(url) { try { url = decodeURIComponent(url); } catch (error) { return false; }

Preview
</li> </ul> </li> </ul> </li> </ul> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li>Use</li> <li class="navBarCell1Rev">Tree</

Preview
--> <html lang="en"> <head> <!-- Generated by javadoc (1.8.0_60) on Tue Nov 03 23:56:56 IST 2015 --> <meta http-equiv="Content-Type"

Preview
name="date" content="2015-11-03"> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <script type="text/javascript" src="script.js"></script> </head> <body> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.to

Preview
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> Class Hierarchy</title> <meta name="date" content="2015-11-03"> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <script type="text/javascript" src="script.js"></script> </head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title=" Class Hierarchy"; } } catch(err) { } //--> </script> <noscript> <

Preview
target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF T

Preview
slider</pre> </li> <li class="blockListLast"> <h4>contentPane</h4> <pre>java.awt.Container contentPane</pre> </li> </ul> </li> </ul> </li> </ul> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li

Preview
getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree</code></li> </ul> <ul class="blockList"> <li cl

Preview
<target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl"> <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> <attribute default="**" name="testincludes"/> <attribute default="" name="testmethods"/> <element implicit="true" name="customize" optional="true"/> <sequenti

Preview
<root id="src.dir"/> </source-roots> <test-roots> <root id="test.src.dir"/>

Preview
Container contentPane; //Content pane /** *Constructor */ public TempConverter() { //Set the title setTitle("Temperature"); //Specify what happens when the //close button is clicked. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create the labels. label1 = new JLabel("Fahrenheit: "); label2 = new JLabel("Centigrade: "); //Create the read-only text fields. fahrenheitTemp = new JTextField("0.0", 10);

Output1.PNG (16 K) Download Preview

Output2.PNG (18 K) Download Preview

Screenshots
Screenshot
Screenshot
Purchase Answer

Thermometer Applet

felo
felo 



Find the source code, use the scroll bar on the left of the applet to control the temperature.

Cheers!
Attachments
ThermometerApplet.rar (25 K) Download










Preview
is found in the SRC folder. If you do this, the IDE will use it when you run or debug the applet. Tip: To exclude an HTML launcher from the JAR file, use exclusion

Preview
</obfuscate> </target> For list of available properties check the imported nbproject/build-impl.xml file. Another way to customize the build is by overriding existing main targets. The targets of interest are: -init-macrodef-javac: defines macro for javac compilation -init-macrodef-junit: defines macro

Preview
<attribute default="" name="testMethod"/> <element implicit="true" name="customize2" optional="true"/> <sequential> <j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}"> <customize2/> </j2seproject3:testng-debug> </sequential> </macrodef> </target> <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit"> <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute

Preview
<project xmlns="http://www.netbeans.org/ns/project/1"> <type>org.netbeans.modules.java.j2seproject</type> <configuration> <data xmlns="http://www.netbeans.org/ns/j2se-project/3"> <name>ThermometerApplet</name>

Preview
init() { slider = new Scrollbar(Scrollbar.VERTICAL, celciusValue, 1, 0, 101); add(slider); slider.addAdjustmentListener(this); } public void paint (Graphics g) { int lowTemp=-20, highTemp=120, xPos=30, yPos=30, width=30, height=150; thermometer(g, 100-celciusValue, lowTemp, highTemp, xPos, yPos, width, height); g.setColor(Color.white); g.drawString(""+((float)(100-celciusValue)*9/5+32), 30,205); g.setColor(Color.black); g.drawString(""+(100-celciusValue), 80,205)

therm.png (107 K) Download Preview

Therm2.png (92 K) Download Preview

Screenshots
Screenshot
Screenshot
Purchase Answer

Thermometer Applet Solution

mariobeka
mariobeka 



Below you will find the implementation java files of the applet heavily commented so you can understand better what was done. Also i included a screen shot of the applet running. Attachments
ThermometerApplet.java (2 K) Download Preview
contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); sliderPanel = createSliderPanel(); thermometerPanel = createThermometerPanel(0); contentPane.add(thermometerPanel, BorderLayout.CENTER); contentPane.add(sliderPanel, BorderLayout.SOUTH); } /** * Creates a slider panels which contains a JSlider component. * * @return The slider panel. */ private JPanel createSliderPanel() { JPanel panel = new JPanel(); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 250,

Thermometer.java (2 K) Download Preview
Font("Helvetica", Font.PLAIN, 8)); FontMetrics f = g.getFontMetrics(); int fHeight = f.getHeight(); // Draw the scale of the thermometer int counter = 10; for (int i = 0; i <=10; i++) { g.drawLine(xOrigin + 24, yOrigin + i*thermometerHeight/10, xOrigin + 29, yOrigin +i*thermometerHeight/10); g.drawString(((MAX_TEMP - MIN_TEMP)/10*(counter)) + " F", xOrigin +

Screen Shot 2015-11-04 at 23.41.38.png (68 K) Download Preview

Screenshots
Screenshot
Purchase Answer