Saturday, July 30, 2011

How to create a dialog-based program in Java?

by Vilchor G. Perdido (eturo)


First in our code is to import the package in the Java API where the JOptionPane is. And it is found at the javax.swing package, so will create a code to import this package. It look like this...

import javax.swing.JOptionPane;
or you may write the code above like this;

import javax.swing.*; //note that the asterisk (*) indicate that all the classes and methods inside this package will be automatically used or include by the program


Second, create a code to define the class name (Note: The class name you entered a while ago is always the same the class name you will write in the code.) Below the class declaration, put a paired of open and close curly bracket where we will put the variables and methods later to be used by our program. The whole class is denoted by the light blue color in the code pad in the BlueJ text editor.

import javax.swing.JOptionPane;
public class MyFirstGUIProgram
     your code here
}

 
Third, after defining your class, the next step is to create the main method to be able to execute by the program. Whatever statements you declared inside the main method will be executed. The main method of our program will be indicated by the light yellow color the code pad window. To create the main method of our program, do this inside the class:


import javax.swing.JOptionPane; //package declaration


public class MyFirstGUIProgram //class definition

{

     public static void main(String[] args) //the main method
     {
         your code here
     }
}


Now, we are ready to create the statement that will display a dialog box with a message. To do this, we have the following syntax in creating a message dialog box.

JOptionPane.showMessageDialog(null,"your message here","text in the title bar", type of dialog box ,);

Explanation:

 


So, in our code:


Thursday, July 14, 2011

Your PC Will Die If You Don't Do These 5 Things

Update Windows

Avoid skipping Windows Update if possible. As the updates are pushed from Microsoft’s server to your computer automatically, install the updates as soon as possible and restart your computer if necessary. While this may be a hassle at times, it does keep your computer safer and improve its stability. 


Microsoft Security Essentials

Regardless of which operating system you are using, Windows, Mac or Linux, there are always viruses out there. Because Windows is the commonly used operating system in the world, you will need an antivirus software to be running in the background. Please do not try to run multiple antivirus softwares on the same system as this will lead to system instability.
Here’s the good news though, there’s no need to pay for an antivirus, for you have Microsoft Security Essentials to turn to. As a matter of fact, Microsoft Security Essentials is pretty great on its own. Findings from AV-Test.org shows it detects 98% of their enormous malware database, and AV-Comparatives.org found MSE to be one of only three products that did well at both finding and removing malware, including the leftovers. On top of that, they are the only free product to achieve an “Advanced+” rating – the top award for an anti-malware solution.
Nevertheless the technically inclined note that MSE does not incorporate fancy heuristics to detect viruses that aren’t already in the database. Whether this is a major weakness, it depends very much if you have the tendency to open files from untrusted sources. For the best defense against malware is safe browsing, with or without antivirus. 

Back Up Your Hard Drive
Be it the simple Windows Backup or other automated offsite backup tool like Crashplan, backups are crucial for any computer user. And it is not just about maintenance, it’s about having access to your files when your computer stops showing any signs of life. And this is one of the most important maintenance you will have to carry out. 

Clean Up Your Temporary Files

It is normal for Windows to have a lot of temporary files stored on your hard drive, mostly from your web surfing, and it is a good idea to clean these up regularly. A great tool for this job is CCleaner, and you can use this to clean up your PC manually or set up an automated schedule, keeping your computer free of all the temporary clutter. 

Completely Uninstall Programs

While Windows’ Add/Remove Programs dialog is a useful feature, Revo Uninstaller is by far better. Not only does it remove all traces of an application from your computer, but it also helps you uninstall apps you can’t locate, in addition to managing your startup processes which can speed up your boot up and run smoother once you do.

Thanks to this link.

Like Us on Facebook

Related Posts Plugin for WordPress, Blogger...