Monday, 6 October 2014

How to Create Restart button in java using NetBean

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.
Requirements: your JAVA IDE  and a little pinch of logic.
1.        Open your Netbean. And start a new Project.
 If you don’t know how to start a new project in NETBEAN check out this tutorial
2.       Add a new JFrame. [Right click on the project name on the projects panel like in my case I right clicked on ShutDownExtended=> select New=>JFrame Form…]. Rename the class to any name you like but note: it must follow these naming conventions.
a.       The Class name must start with an Upper letter e.g Gandhi.
b.      Every word must be joint together with an uppercase letter starting each word e.g Gandhi Berry should be written as GandhiBerry.
c.       And No a class name cannot start with numbers
3.       On the Form drag in 6 buttons and one text field. Don’t ask me why just drag.
4.       Now rename each button to make your interface to like mine.
5.       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.
Runtime r= Runtime.getRuntime();

6.       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.
                Process Proc=r.exec(“Shutdown –s –t 0”);
}catch(Exception Ex){
You can perform an emergency shutdown by changing the –t to –p and see how that goes.
7.       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.
8.       To create the restart button, click on design then double click on the restart button and add these codes.
                                Process Proc=r exec(“Shutdown –r –t 0”);
                                }catch(Exception Ex){
9.       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.


You can prevent a shutdown by using this button immediately after clicking shutdown.

10.   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 Timed shutdown button. And type these codes
int x;
    Process Proc =r.exec("Shutdown -s -t" + x);
                  }catch(Exception Ex){

Wednesday, 24 September 2014

Creating a shutdown button using java Netbean GUI

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.
 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 for instructions.

Tuesday, 23 September 2014

Example of a two dimensional array using basic program (QBASIC)

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.

here is the code: