tag:blogger.com,1999:blog-55488416729025631522024-03-06T00:18:34.222-08:00Dimconnectnetworking the worldAnonymoushttp://www.blogger.com/profile/00749702988968146260noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-5548841672902563152.post-20763398369875637302014-10-06T02:26:00.000-07:002014-10-18T21:10:18.920-07:00How to Create Restart button in java using NetBean<div dir="ltr" style="text-align: left;" trbidi="on"><div class="Publishwithline"><br></div>
<div class="MsoNormal">
Hey having fun with the shutdown? Well I have lots of other
stuffs like how to extend the shutdown button so as you could hibernate sleep
and even restart your system. You can even add delay time before the shutdown. If
you haven’t seen our tutorial on shutdown, please click this link.</div>
<div class="MsoNormal">
Requirements: your JAVA IDE<span style="mso-spacerun: yes;">
</span>and a little pinch of logic.</div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">1.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><span style="mso-spacerun: yes;"> </span>Open your
Netbean. And start a new Project.</div>
<div class="MsoNormal" style="text-indent: .5in;">
<span style="mso-spacerun: yes;"> </span>If you don’t know how to start a new project
in NETBEAN check out this tutorial</div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">2.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Add a new JFrame. [Right click on the project
name on the projects panel like in my case I right clicked on <b style="mso-bidi-font-weight: normal;">ShutDownExtended=> select New=>JFrame
Form…</b>]. Rename the class to any name you like but note: it must follow
these naming conventions. </div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">a.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>The Class name must start with an Upper letter
e.g Gandhi.</div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">b.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Every word must be joint together with an uppercase
letter starting each word e.g Gandhi Berry should be written as GandhiBerry.</div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">c.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>And No a class name cannot start with numbers</div>
<div class="MsoNormal">
<span style="mso-no-proof: yes;"><img height="374" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image002.jpg" width="508"></span></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">3.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>On the Form drag in 6 buttons and one text field.
Don’t ask me why just drag.</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">4.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Now rename each button to make your interface to
like mine.</div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-no-proof: yes;"><img height="308" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image004.jpg" width="430"></span></div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">5.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Now we begin the coding. Double click on the
shutdown Button. It takes you to the code window. Normally we are supposed to
type our codes in the area we find our cursor blinking but we aren’t gonna do
that. Instead click outside of the ending curly brace “}” and then type this
command like so.</div>
<div class="MsoNormal" style="margin-left: 1.0in;">
Runtime r= Runtime.getRuntime();</div>
<div class="MsoNormal" style="margin-left: 1.0in;">
<br></div>
<div class="MsoNormal" style="margin-left: 1.0in;">
<span style="mso-no-proof: yes;"><img height="81" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image006.jpg" width="673"></span></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">6.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Now return your cursor back to where it was
blinking at first before you changed its location. In between the curly braces “{“
and “}” type this code.</div>
<div class="MsoNormal" style="margin-left: 1.0in;">
Try{</div>
<div class="MsoNormal" style="margin-left: 1.0in;">
<span style="mso-tab-count: 1;"> </span>Process
Proc=r.exec(“Shutdown –s –t 0”);</div>
<div class="MsoNormal" style="margin-left: 1.0in;">
}catch(Exception Ex){</div>
<div class="MsoNormal" style="margin-left: 1.0in;">
}</div>
<div class="MsoNormal" style="margin-left: 1.0in;">
<span style="mso-no-proof: yes;"><img height="164" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image008.jpg" width="831"></span></div>
<div class="MsoNormal" style="margin-left: 1.0in;">
You can perform an emergency
shutdown by changing the –t to –p and see how that goes.</div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">7.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Nice we just added our shutdown code again but
this time the runtime object is outside of the class. Reason is because we want
this object to be accessible by other methods so we had to do that.</div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">8.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>To create the <b style="mso-bidi-font-weight: normal;">restart</b> button, click on design then double click on the<b style="mso-bidi-font-weight: normal;"> restart</b> button and add these codes.</div>
<div class="MsoNormal" style="margin-left: .75in; text-indent: .25in;">
Try{</div>
<div class="MsoNormal" style="text-indent: .5in;">
<span style="mso-tab-count: 1;"> </span><span style="mso-tab-count: 1;"> </span>Process Proc=r exec(“Shutdown –r
–t 0”);</div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 2;"> </span>}catch(Exception
Ex){</div>
<div class="MsoNormal" style="margin-left: .75in; text-indent: .25in;">
}</div>
<div class="MsoNormal">
<span style="mso-no-proof: yes;"><img height="139" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image010.jpg" width="740"></span></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">9.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Repeat step 8 for logoff, hibernate and abort
but change –r to –I for logoff, change –r to –h for hibernate and change –r to –a
for abort. </div>
<div class="MsoNormal">
<br></div>
<div class="MsoNormal">
<span style="mso-no-proof: yes;">LOGGOFF</span></div>
<div class="MsoNormal">
<span style="mso-no-proof: yes;"><img height="129" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image012.jpg" width="589"></span></div>
<div class="MsoNormal">
<span style="mso-spacerun: yes;"> </span>HIBERNATE</div>
<div class="MsoNormal">
<br></div>
<div class="MsoNormal">
<span style="mso-no-proof: yes;"><img height="134" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image014.jpg" width="575"></span></div>
<div class="MsoNormal" style="margin-left: .5in;">
<br></div>
<div class="MsoNormal">
ABORT:</div>
<div class="MsoNormal">
You can prevent a shutdown by using this button immediately
after clicking shutdown.</div>
<div class="MsoNormal">
<br></div>
<div class="MsoNormal">
<span style="mso-no-proof: yes;"><img height="124" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image016.jpg" width="550"></span></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"><span style="mso-list: Ignore;">10.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>To make the timed shutdown we will let the user
to enter how many seconds he/ she wants the system to delay before shutting
down. Note the highest number of time is 10 years so if you want more than that,
ask Microsoft. Double click on the <b style="mso-bidi-font-weight: normal;">Timed
shutdown</b> button. And type these codes</div>
<div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">
int x;</div>
<div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">
<span style="mso-spacerun: yes;"> </span>if(jTextField1.getText().isEmpty()){</div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="mso-spacerun: yes;">
</span><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span>x=0;</div>
<div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">
<span style="mso-spacerun: yes;"> </span>}else{</div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 2;"> </span><span style="mso-spacerun: yes;"> </span>x=Integer.parseInt(jTextField1.getText());</div>
<div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">
<span style="mso-spacerun: yes;"> </span>}</div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="mso-spacerun: yes;">
</span></div>
<div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">
<span style="mso-spacerun: yes;"> </span>try{</div>
<div class="MsoNormal" style="margin-left: .5in; text-indent: .5in;">
<span style="mso-spacerun: yes;"> </span>Process Proc =r.exec("Shutdown -s
-t" + x);</div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="mso-spacerun: yes;">
</span><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span>}catch(Exception Ex){</div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="mso-spacerun: yes;">
</span><span style="mso-tab-count: 1;"> </span>}</div>
<div class="MsoNormal" style="margin-left: .5in;">
<br></div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="mso-no-proof: yes;"><img height="274" src="file:///C:/Users/DARKLO%7E1/AppData/Local/Temp/msohtmlclip1/01/clip_image018.jpg" width="600"></span></div>
</div>
<div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTDORBaXHvDa1jhL9-jjwevrWHTzf60Sxxlc-48YZQ8Tfv8fU0hXsqZfSgZhUAWR-Hr8h54tnE-nZDA0kokaB0H1NaiR4ENkyKMfZxdREc4H1-JGUgilFwAi0MAC4CVQpLM7kHVTXw2T4/s1600/start.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTDORBaXHvDa1jhL9-jjwevrWHTzf60Sxxlc-48YZQ8Tfv8fU0hXsqZfSgZhUAWR-Hr8h54tnE-nZDA0kokaB0H1NaiR4ENkyKMfZxdREc4H1-JGUgilFwAi0MAC4CVQpLM7kHVTXw2T4/s640/start.png"> </a> </div><div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibe1ac-vEhpVtALOK0mIUUUh41QAGEbSkUANgdTf9ilRAHTHq3hNxFp5ropvAA19CErLi7fmOOu1lhbiUt_B-RA583DyCghpCV8_KwxQOz0O4vqWWDwOuZjiCj0xV2mGS-CQwsHxz3vmc/s1600/interface.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibe1ac-vEhpVtALOK0mIUUUh41QAGEbSkUANgdTf9ilRAHTHq3hNxFp5ropvAA19CErLi7fmOOu1lhbiUt_B-RA583DyCghpCV8_KwxQOz0O4vqWWDwOuZjiCj0xV2mGS-CQwsHxz3vmc/s640/interface.png"> </a> </div><div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZf2J1i1r3RLGG44q-Mt0eF-Y5jMgXYAfF8aA1wL5Bkvmxo-yRM5H-vUfHmIDE-y2U1sNAiIm8sbGFlU7U5GbPSalzmZyjNOh0fNVtXvXRfrzGHyg7O8gjpqnawRFnRrupkMoQ4r7tOAE/s1600/runtime.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZf2J1i1r3RLGG44q-Mt0eF-Y5jMgXYAfF8aA1wL5Bkvmxo-yRM5H-vUfHmIDE-y2U1sNAiIm8sbGFlU7U5GbPSalzmZyjNOh0fNVtXvXRfrzGHyg7O8gjpqnawRFnRrupkMoQ4r7tOAE/s640/runtime.png"> </a> </div><div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqpAuGhw10IALCVA4Rs1Dj_nRf9iSQByLSXCF1tks71q4vLXnvpuxrygGvopVmNtTagxKOEyBjbGO7vxjyhWIsagEPWb7Ty8XUBg3P2keq_JnL-eZIodPcmIhNNTJ1scGVKHM-fdpchM0/s1600/shutdown.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqpAuGhw10IALCVA4Rs1Dj_nRf9iSQByLSXCF1tks71q4vLXnvpuxrygGvopVmNtTagxKOEyBjbGO7vxjyhWIsagEPWb7Ty8XUBg3P2keq_JnL-eZIodPcmIhNNTJ1scGVKHM-fdpchM0/s640/shutdown.png"> </a> </div><div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiqB-4nwdCK24Z4MYAWT_ctXXBi7zzFJJMPlq5Qh9MJab0zC85oiMLbfd1QSOw2OCmj1O62W8TAzie4A0q5ScwDtgc62t7ZvhHcfNfgqjLrhfZF9pY5B4O9Sukjf32koNNmFkXA0-CARI/s1600/restart.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiqB-4nwdCK24Z4MYAWT_ctXXBi7zzFJJMPlq5Qh9MJab0zC85oiMLbfd1QSOw2OCmj1O62W8TAzie4A0q5ScwDtgc62t7ZvhHcfNfgqjLrhfZF9pY5B4O9Sukjf32koNNmFkXA0-CARI/s640/restart.png"> </a> </div><div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Xs6u2j6LG78RmKvF6oMRHESbEbJDf1yfQfZvMPnGxPY7CbdUEVEu-x8j2LWUfcMncSodlWEX03T7TttrFl7Fgwd1Xg74FjC-7ylExIjMIIuALkL-vAcF2vycG9EUgZC2ANCGzUnqxuk/s1600/abort.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Xs6u2j6LG78RmKvF6oMRHESbEbJDf1yfQfZvMPnGxPY7CbdUEVEu-x8j2LWUfcMncSodlWEX03T7TttrFl7Fgwd1Xg74FjC-7ylExIjMIIuALkL-vAcF2vycG9EUgZC2ANCGzUnqxuk/s640/abort.png"> </a> </div><div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaDLPmRiSMfjSI5p2XfetKYu0Kth7D37L-mrFtTIubN6c50jXXLNDVYIE42vArVzXE6e6eVL4OvMV9J2ekztgLki9sGXM_6mUYDoiIJyIY3iQJO1tEfQANMJjFP4y-XHE205801Rli-jQ/s1600/logoff.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaDLPmRiSMfjSI5p2XfetKYu0Kth7D37L-mrFtTIubN6c50jXXLNDVYIE42vArVzXE6e6eVL4OvMV9J2ekztgLki9sGXM_6mUYDoiIJyIY3iQJO1tEfQANMJjFP4y-XHE205801Rli-jQ/s640/logoff.png"> </a> </div><div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWfIXcKfKY820VnhNPF1HYz5GF4sm2Tv_nj7ueWGaEpWquneVWK1WLCIY9jmG4KA2KWmIYZCiK4fo7HnkFMx2AOoZ1sewi4It7Tn6pedsaOHEj1n5aexJzq8x_mFrWPbAcaILm_dwuBV4/s1600/hibernate.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWfIXcKfKY820VnhNPF1HYz5GF4sm2Tv_nj7ueWGaEpWquneVWK1WLCIY9jmG4KA2KWmIYZCiK4fo7HnkFMx2AOoZ1sewi4It7Tn6pedsaOHEj1n5aexJzq8x_mFrWPbAcaILm_dwuBV4/s640/hibernate.png"> </a> </div>Anonymoushttp://www.blogger.com/profile/00749702988968146260noreply@blogger.com0tag:blogger.com,1999:blog-5548841672902563152.post-85211728808461798162014-09-24T15:39:00.000-07:002014-09-25T10:07:16.420-07:00Creating a shutdown button using java Netbean GUI<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
Creating a shutdown using java NETBEAN is very easy, even if you are an amateur in the language. We’ll be creating one in GUI (graphical user interface). By this I mean using drag and drop and letting the system do some of the coding for you. <br />
Before we start there are some requirements you need they are JDK (java development kit) and your NETBEAN installer I will recommend netbean 7.1.2 it is what I am using and its ok. If you want more instructions on how to install the product you can check http://www.netbeans.org/kb/index.html for instructions. <br />
<a name='more'></a><br />
<h3 style="text-align: left;">
<b>STEPS TO CREATE SHUTDOWN BUTTON. </b></h3>
<ul style="text-align: left;">
<li>Open your NETBEAN. On the menu bar click on <b>File => New Project.</b></li>
</ul>
<ul style="text-align: left;">
<li><b> </b>Under categories click java, under projects select Java application then click on next. </li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio0cIxBrKnTaoFlvFgFrSTsJTH_FJTYgCu6U0jWYYrN0_ZCV0-XWKTXrdR6ZqOK8U-EfNUpvSelsbNKm9C3SlfgRIxriQenagjAaLAnMLEHCsoXP2bJ097jgorppIL3KY7yLPfB5ty4-o/s1600/image2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio0cIxBrKnTaoFlvFgFrSTsJTH_FJTYgCu6U0jWYYrN0_ZCV0-XWKTXrdR6ZqOK8U-EfNUpvSelsbNKm9C3SlfgRIxriQenagjAaLAnMLEHCsoXP2bJ097jgorppIL3KY7yLPfB5ty4-o/s1600/image2.png" height="222" width="320" /></a></div>
<ul style="text-align: left;">
<li>A second form pops up, on the project this is the form that lets you to insert your project name. Enter MyShutDown as project name, uncheck create as main class since we don’t want it to be our main class then click on finish. </li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNaKk7bbn2qvJz_U7r03A63GKJxOTCAxcNNcLtCchHXNOjsYARWPdun-wSW9VcIV6fxJdmnmMdfqjD7T2rxgO1qHpjaCv4n7MtjSlQptF2-jojLpqc-IYfaYMn4TL1hjLBydn7egy05KQ/s1600/image3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNaKk7bbn2qvJz_U7r03A63GKJxOTCAxcNNcLtCchHXNOjsYARWPdun-wSW9VcIV6fxJdmnmMdfqjD7T2rxgO1qHpjaCv4n7MtjSlQptF2-jojLpqc-IYfaYMn4TL1hjLBydn7egy05KQ/s1600/image3.png" height="222" width="320" /></a></div>
<br />
<br />
<ul style="text-align: left;">
<li>The project is now created. To add a form or jFrame, Right click on MyShutDown under the project panel, click on <b>New => JFrame form…</b> </li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7xPEy96PxvR6b6kfOCnR9m7oJNOR7XCtdPy2E3CS4J7Gpr3KJNvr7tZDPkrzfILKQBRuO9K4y3pVb1kH9LFqjKr4WaDSC20I6TqLu-dmjzjoK0OleOuqyIAgf3m3YRSPNvxaQKnDgsoQ/s1600/image4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7xPEy96PxvR6b6kfOCnR9m7oJNOR7XCtdPy2E3CS4J7Gpr3KJNvr7tZDPkrzfILKQBRuO9K4y3pVb1kH9LFqjKr4WaDSC20I6TqLu-dmjzjoK0OleOuqyIAgf3m3YRSPNvxaQKnDgsoQ/s1600/image4.png" height="153" width="320" /></a></div>
<ul style="text-align: left;">
<li>A pop up window appears Enter ShutDown for the class name. under the package name enter my.(name of the project) in our case it would be my.MyShutDown. click finish button a new interface pops up as shown below </li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpqx8hPwP6x6jLWeZV8YYxKNK6xTIhTo-JWU9-hp_Tbbod-Y-Rwhe5G_k9fybw5kdN-BJc83mrQJ1cZBklp09dHj1YyegF77gNRu9Fhf9sYQV3XouFwsHw68bfHtgL94WbXg1FJvSV8mo/s1600/image5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpqx8hPwP6x6jLWeZV8YYxKNK6xTIhTo-JWU9-hp_Tbbod-Y-Rwhe5G_k9fybw5kdN-BJc83mrQJ1cZBklp09dHj1YyegF77gNRu9Fhf9sYQV3XouFwsHw68bfHtgL94WbXg1FJvSV8mo/s1600/image5.png" height="116" width="320" /></a></div>
<br />
<ul style="text-align: left;">
<li>From the palette menu at the right hand side of your screen, drag a button to the form. If you can’t find your palette on your screen just hold these keys down ctrl+shift+8. </li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhThgyDZOWzwwsPpwe51ImaApoAR7CmVB_rd42OaMeHSYLEagJeVqR92ul_rH2iKmnqM5JH6EiVHrPfV1VEPtj82ZECkeIDo1H_NVArg0tAfr2q8FEO2pfz8mvmrbnVbvdvoiKshcs95I/s1600/image6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhThgyDZOWzwwsPpwe51ImaApoAR7CmVB_rd42OaMeHSYLEagJeVqR92ul_rH2iKmnqM5JH6EiVHrPfV1VEPtj82ZECkeIDo1H_NVArg0tAfr2q8FEO2pfz8mvmrbnVbvdvoiKshcs95I/s1600/image6.png" height="187" width="320" /></a></div>
<ul style="text-align: left;">
<li>Right Click on the button, and select Edit Text . Rename the button to Shutdown. </li>
</ul>
<ul style="text-align: left;">
<li>Right Click on the button again and select events => Action => ActionPerformed. The code menu appears inside of it (I.e where the cursor is blinking) type this code: </li>
</ul>
<div style="text-align: left;">
<pre>try{ </pre>
</div>
<div style="text-align: left;">
Runtime runtime=Runtime.getRuntime(); </div>
<div style="text-align: left;">
Process Proc=runtime.exec("Shutdown -s -t 0"); </div>
<div style="text-align: left;">
}catch(Exception e){ </div>
<div style="text-align: left;">
}
</div>
</div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/00749702988968146260noreply@blogger.com0tag:blogger.com,1999:blog-5548841672902563152.post-28298795044828961672014-09-23T05:47:00.000-07:002014-09-25T10:07:41.461-07:00Example of a two dimensional array using basic program (QBASIC)<div dir="ltr" style="text-align: left;" trbidi="on">
This is a sample on writing two dimensional array with Qbasic its kind of easy all you just need is to understand how it works.<br />
<br />
here is the code:<br />
<br />
<a name='more'></a><br /><br />
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;">DIM vars(2, 2) AS INTEGER</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;">vars(1, 1) = 1</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;">vars(1, 2) = 1</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"> vars(2, 1) = 2 </span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;">vars(2, 2) = 2</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;">FOR y = 1 to 2</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"> FOR x = 1 to 2</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"> PRINT vars(y,x),</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"> NEXT x</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;"> PRINT</span></div>
<div class="MsoNormal">
<span style="font-family: Courier New, Courier, monospace;">NEXT y</span></div>
<div>
<br /></div>
<div class="MsoNormal" style="text-align: left;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="MsoNormal" style="text-align: left;">
The first line declares the type of array you want to make like in this case, its a 2 x 2 array.</div>
<div class="MsoNormal" style="text-align: left;">
The second line to the forth line initializes the array. i.e it gives value to the array the the last lines print the arrays to the screen.</div>
<div class="MsoNormal" style="text-align: left;">
Please feel free to comment and like our page on facebook</div>
</div>
Anonymoushttp://www.blogger.com/profile/00749702988968146260noreply@blogger.com4