Tuesday, January 13, 2009

Change Font in Java

This is an example code how to change a font in Java application.

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.FlowLayout;
import java.awt.Font;

public class Teks extends JFrame {
JLabel lbl1 = new JLabel(”Helvetica biasa”);
JLabel lbl2 = new JLabel(”SansSerif bold”);
JLabel lbl3 = new JLabel(”Monospaced italic”);
JLabel lbl4 = new JLabel(”Serif biasa”);

public Teks()
{
setTitle(”Font”);
setApplicationLayout();
setSize(175,200);
setLocationRelativeTo(null);
setVisible(true);
}

public static void main(String args[])
{
Teks teks = new Teks();
teks.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void setApplicationLayout()
{
setLayout(new FlowLayout());
lbl1.setFont(new Font (”Helvetica”, Font.PLAIN, 16));
lbl2.setFont(new Font (”SansSerif”, Font.BOLD, 16));
lbl3.setFont(new Font (”Monospaced”, Font.ITALIC, 16));
lbl4.setFont(new Font (”Serif”, Font.PLAIN, 24));
add(lbl1);
add(lbl2);
add(lbl3);
add(lbl4);
}
}

Best regards,

Deny Sutani

Digital Clock in Java

Oneday, my friend ask about how to make digital clock in java. It's like a timer, when the second has reach 60, the minute will be added by 1, when the minute reach 60, the hour will be added by 1.

This is the code. Hope this code will be useful not only for my friend, but also other people who need it.

import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.FlowLayout;

public class Jam extends JFrame {

private Timer timer;

int detik,menit,jam = 0;

JLabel lblDetik = new JLabel(”");
JLabel lblMenit = new JLabel(”");
JLabel lblJam = new JLabel(”");

public Jam()
{
setTitle(”Jam”);
setApplicationLayout();
setSize(150,75);
setLocationRelativeTo(null);
setVisible(true);
}

public static void main(String args[])
{
Jam jam = new Jam();
jam.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

class PuterJam extends TimerTask
{
public void run()
{
detik++;
if(detik==60)
{
detik=0;
menit++;
}
if(menit==60)
{
menit=0;
jam++;
}
if(detik<10) lblDetik.setText(”0″+detik);
else lblDetik.setText(”"+detik);

if(menit<10) lblMenit.setText(”0″+menit+” : “);
else lblMenit.setText(”"+menit+” : “);

if(jam<10) lblJam.setText(”0″+jam+” : “);
else lblJam.setText(”"+jam+” : “);
}
}

public void setApplicationLayout()
{
timer = new Timer();
timer.schedule(new PuterJam(), 0,1*1000);
setLayout(new FlowLayout());
add(lblJam);
add(lblMenit);
add(lblDetik);

}

}

Best regards,

Deny Sutani

Insert an Icon to JInternalFrame

Often, we insert an icon into a JFrame in Java application, but how to insert an icon into JInternalFrame? It's almost the same, it's only need to use different method. We can user setFrameIcon() method.

This is the snippet code
URL url = getClass().getResource(”image/login.gif”);
Icon icon = new ImageIcon(url);
setFrameIcon(icon);

Best regards,

Deny Sutani

A Computer And Internet Glossary

When you use computers and the Internet in your business, it's all too easy to start feeling like you're drowning in a sea of nonsense. Computer-related things tend to have a language all their own, and while you don't need to know all of it, there are many confusing words and phrases that you're going to come across sooner or later. Here's a quick primer.

Bandwidth. Bandwidth is the amount of data that your website can send each second, as well as the amount of data that the visitor to your website can receive. If either one doesn't have enough bandwidth, then the website will appear slowly. For this reason, you should choose a host with plenty of bandwidth, as well as testing that your site doesn't take too long to download on slow connections.

Browser. A browser is the software (see below) that visitors to your site use to view it. The most popular browser is Microsoft's Internet Explorer, which comes with Windows.

Cookie. Cookies are data files that your site can save on the computer of someone who visits that site, to allow it to remember who they are if they return. You will find that problems people have in ordering from you will almost inevitably be related to cookies -- they will need to have them turned on.

Download. Transferring data from a website to a computer.

Favourite. A favourite is a website that a user has stored to look at again, by choosing 'Add to Favourites' in their browser's menu.

FTP. File Transfer Protocol. This is a common method of uploading (see below) files to your website.

Javascript. A common language for writing 'scripts' on websites, which are small programs that make the site more interactive. Another common cause of problems for visitors.

JPEG. Joint Photographic Experts Group. This is the name of the most popular format for pictures on the web, named after the group that came up with it. If you want to put pictures on your website, you should save them as JPEGs.

Hardware. Hardware is computer equipment that physically exists. It is the opposite of software.

Hosting. If you've got a website out there on the Internet, then you'll be paying someone for hosting. It is the service of making your site available for people to see.

HTML. HyperText Markup Language. A kind of code used to indicate how web pages should be displayed, using a system of small 'tags'. The 'b' tag, for example, causes text to appear in bold, and the 'img' tag displays a picture.

Hyperlink. A hyperlink is when a piece of text on a website can be clicked to take you to another site, or another page on the same site. For example, if clicking your email address on your website allows someone to email you, then your email address is a hyperlink.

Programming. This is when the computer is given instructions to tell it what to do, using one of many 'programming languages'. Programming languages for the web include PHP and Perl.

Server. The server is where your website is stored, and it is the server that people are connecting to when they visit the site. If someone tells you, for example, that your server is 'down', it means that your website is inaccessible. Note that server refers both to the hardware and software of this system.

Software. Programs that run on the computer, or that make your website work. Microsoft Word is software, for example, as is Apache (the most popular web server software). Opposite of hardware.

Spider. Don't be scared if a spider visits your website! Spiders are simply programs used by search engines to scan your site and help them decide where it should appear when people search. It is good to be visited by spiders, as it means you should start appearing in search engines soon.

Upload. Uploading is when you transfer data from your own computer to your website. For example, you might upload your logo, or an article you've written. Opposite of download.

URL. Uniform Resource Locator. This is just a short way of saying 'web address', meaning what you have to type in to get to your website. Sometimes pronounced as 'Earl'.

A Close Look At DVI Cables

We all have many times heard about DVI, but what does it really means and what it does? What is the main function of this tiny white port on a video card? How it can benefit you and your personal computer? Do you know which DVI is suitable to meet your requirements?

Digital Video Interface is created by Digital Display Working Group to solve the problem of accommodation analog and digital interfaces just by using single connector. It was developed because of insufficiency of standardization in digital interfacing.

Three types of standards can be seen in DVI cables. It is very important to know how each type looks like before buying to upgrade your DVI. So it is very important to know how DVI cable works and which one will be most beneficial for you.

However, DVI cables are still in the phase of development. Hence there is no specific standard for the DVI cable. In ideal circumstances, DVI home theater cable is capable to create ' digital to digital' connection between the data or video sources and home theater projectors.

The standard rule for DVI cables is that it should have maximum length of 5 m for trouble free operation. It is very typical to decide a DVI cable first time.

There are two types of DVI connector and each has its own characteristics. The flat pin denotes whether the cable is analog or digital. A flat pin with four surrounding pins denotes either DVI-A or DVI-1. A single flat pin denotes DVI-D. The pin sets depends upon whether the cable is single link or dual link or analog.

To choose a perfect Digital video interface cable you should remember these tips:

1.Check both female DVI plugs to make sure what type of signals they compatible with.
2.One or both connections should be DVI-D if you are choosing a DVI-D cable.
3.One or both connections should be DVI-A if you are choosing a DVI-a cable.
4.If one of the connections is DVI and other is VGA, and if the DVI is analog compatible, then you must buy a DVI/VGA adaptor or a DVI to VGA cable.
5.when both connections are DVI-1, you are advised to use any of DVI cable, but better if you use DVI-1 cable.
6. If one connection is digital and the other is analog then there is no possibility of connection between them.

A Brief Introduction To Fiber Optics Technology

Understanding how fiber optics are made and function for uses in everyday life is an intriguing work of art combined with science. Fiber optics has been fabricated from materials that transmit light and are made from a bundle of very thin glass or plastic fibers enclosed in a tube. One end is at a source of light and the other end is a camera lens, used to channel light and images around the bends and corners. Fiber optics have a highly transparent core of glass, or plastic encircled by a covering called "cladding". Light is stimulated through a source on one end of the fiber optic and as the light travels through the tube, the cladding is there to keep it all inside. A bundle of fiber optics may be bent or twisted without distorting the image, as the cladding is designed to reflect these lighting images from inside the surface. This fiber optic light source can carry light over mass distances, ranging from a few inches to over 100 miles.

There are two kinds of fiber optics. The single-mode fiber optic is used for high speed and long distance transmissions because they have extremely tiny cores and they accept light only along the axis of the fibers. Tiny lasers send light directly into the fiber optic where there are low-loss connectors used to join the fibers within the system without substantially degrading the light signal. Then there are multi-mode which have much larger cores and accept light from a variety of angles and can use more types of light sources. Multi-mode fiber optics also use less expensive connectors, but they cannot be used over long distances as with the single-mode fiber optics.

Fiber optics have a large variety of uses. Most common and widely used in communication systems, fiber optic communication systems have a variety of features that make it superior to the systems that use the traditional copper cables. The use of fiber optics with these systems use a larger information-carrying capacity where they are not hassled with electrical interference and require fewer amplifiers then the copper cable systems. Fiber optic communication systems are installed in large networks of fiber optic bundles all around the world and even under the oceans. Many fiber optic testers are available to provide you with the best fiber optic equipment.

In fiber optic communication systems, lasers are used to transmit messages in numeric code by flashing on and off at high speeds. This code can constitute a voice or an electronic file containing, text, numbers, or illustrations, all by using fiber optics. The light from many lasers are added together onto a single fiber optic enabling thousands of currents of data to pass through a single fiber optic cable at one time. This data will travel through the fiber optics and into interpreting devices to convert the messages back into the form of its original signals. Industries also use fiber optics to measure temperatures, pressure, acceleration and voltage, among an assortment of other uses.

10 Tips For Overcoming Procrastination At The PC

Copyright 2006 Michael Madigan

Procrastination is the thief of time - and money too, at the PC. Your Internet connection, equipment and power cost you. Some tasks are no fun - but don't let them pile up. Constant dithering and delaying will wreck your health, wealth and reputation.

Here are 10 tips for helping you stop procrastination dead:

1/ Before you even sit down, sort out in your mind what’s 'urgent', 'important', both, or neither. (If an 'urgent' task isn't 'important' and the deadline passes, so what?). An 'urgent and important' task should normally come before an 'important' task. If you have a poor memory (like me) write or type a quick list of your Top Five To Dos for the session, and delete or amend as need be.

2/ All other things being equal plan on doing easy tasks before difficult short tasks before long tasks. Always have something concrete to show for worktime in front of your PC.

3/ As far as you can YOU decide what' important' and 'urgent'. There are bullies about - bosses, colleagues and customers - who think their merest whim is law. Learn to say 'No' politely. They may not like it, especially at first. But you'll grow.

4/ If you need help for your work, get it now, not later. If it’s not there now, you can ask later - more chances. If you leave it till later, it may have gone off earlier so no chances....

5/ You’re there going thru your emails, databases and memos and suddenly out of nowhere, new jobs appear. The tendency is to 'do what's on top of the pile' first. Don't. Put it into the right place in your existing list.

6/ Do you get distracted easily? Try and be aware of this, and stay aware of what tasks need doing - and by when.

7/ Are you more energetic and creative morning, noon or night? Can you reschedule your targets to take this into account? Or do you just plod along, whatever? You may be a tortoise or a hare, but you can still win your own personal race if you plan ahead.

8/ Don't give up your breaks. You need to pace yourself. But put a time limit on all breaks, surfing, chatting or just daydreaming can eat into worktime with disastrous results. A rushed job is rarely your best shot, or a true reflection of your abilities.

9/ Be particularly wary of long lunch breaks, and overeating or drinking. If your afternoon's festooned with urgent and important chores, you’ll feel inclined to procrastinate bigtime if you're hung over, stuffed to the gills, or dead beat.

10/ Give yourself a treat if you hit all your deadlines. Doesn't have to be chocolate! And don't procrastinate on rewarding yourself when you deserve it.

Use these tips to stop procrastination at the PC (AND off), and it’ll boost your free time and make you happy and healthy computing thru 2006 and beyond!

10 Tips For Overcoming Procrastination At The PC

Copyright 2006 Michael Madigan

Procrastination is the thief of time - and money too, at the PC. Your Internet connection, equipment and power cost you. Some tasks are no fun - but don't let them pile up. Constant dithering and delaying will wreck your health, wealth and reputation.

Here are 10 tips for helping you stop procrastination dead:

1/ Before you even sit down, sort out in your mind what’s 'urgent', 'important', both, or neither. (If an 'urgent' task isn't 'important' and the deadline passes, so what?). An 'urgent and important' task should normally come before an 'important' task. If you have a poor memory (like me) write or type a quick list of your Top Five To Dos for the session, and delete or amend as need be.

2/ All other things being equal plan on doing easy tasks before difficult short tasks before long tasks. Always have something concrete to show for worktime in front of your PC.

3/ As far as you can YOU decide what' important' and 'urgent'. There are bullies about - bosses, colleagues and customers - who think their merest whim is law. Learn to say 'No' politely. They may not like it, especially at first. But you'll grow.

4/ If you need help for your work, get it now, not later. If it’s not there now, you can ask later - more chances. If you leave it till later, it may have gone off earlier so no chances....

5/ You’re there going thru your emails, databases and memos and suddenly out of nowhere, new jobs appear. The tendency is to 'do what's on top of the pile' first. Don't. Put it into the right place in your existing list.

6/ Do you get distracted easily? Try and be aware of this, and stay aware of what tasks need doing - and by when.

7/ Are you more energetic and creative morning, noon or night? Can you reschedule your targets to take this into account? Or do you just plod along, whatever? You may be a tortoise or a hare, but you can still win your own personal race if you plan ahead.

8/ Don't give up your breaks. You need to pace yourself. But put a time limit on all breaks, surfing, chatting or just daydreaming can eat into worktime with disastrous results. A rushed job is rarely your best shot, or a true reflection of your abilities.

9/ Be particularly wary of long lunch breaks, and overeating or drinking. If your afternoon's festooned with urgent and important chores, you’ll feel inclined to procrastinate bigtime if you're hung over, stuffed to the gills, or dead beat.

10/ Give yourself a treat if you hit all your deadlines. Doesn't have to be chocolate! And don't procrastinate on rewarding yourself when you deserve it.

Use these tips to stop procrastination at the PC (AND off), and it’ll boost your free time and make you happy and healthy computing thru 2006 and beyond!

10 Web Site Backup Essentials That You Should Live By

More and more webmasters nowadays do not value the importance of a complete website backup (files and databases). They have left this to chance and good luck which poses a great risk to their online presence.

Can you relate to this? Then read this important article which might save you an arm and a leg later.

Web site backup is the most ignored task of the webmasters simply because it poses no immediate threat to them until something worse happen to their hosting server. Many times, this task is set aside, delayed and even regarded as nuisance to the busy website owner.

They just don't realize what is at stake here.

So before your website will be wiped out of the internet by unexpected accidents like server breakdowns, harddisk failures, hacking and DDOS attacks among other bad things, let me share with you the 10 Backup E-S-S-E-N-T-I-A-L-S you should not live without online.

EXPECT - Know that your webhosting company (even the biggest and the most boastful out there) may encounter problems and that your diligence to backup up will pay off later on. Online computing has never been so unpredictable that the worse of times will happen when you least expect it. With the proper mindset, you are insuring the continuity of your online endeavour in any eventualities. In short, be ready.

SCHEDULE - Your backup process should not compete with your busy schedules. Create your own backup schedule at the most convenient time for you in the week. If you're like me, I do this during lunch and dinner times. Sometimes, I have to leave my PC overnight working on the backups. If you can make it not to conflict with your busy schedules, you will be able to keep up with the demands of this job. In short, don't complicate.

STICK with it - Just do it. Patience is key to your backup tasks. Once you have a schedule, stick with it. You must do this diligently every time it should happen. This is a tough challenge especially to busy people working online. But the sooner you discipline yourself and make backing up your files a habit, the more you will benefit from a worry-free online environment. In short, get a good habit.

EVALUATE - After a while, test your backup files. A good backup can be tested by simply restoring it on another system. Evaluating your backup results from time to time is good way to know that you are keeping what you should keep - a good and working backup. In short, be sure.

NO Complacency - After some time, your backup schedule may slip away and you will tend to forget or intentionally miss it. Don't succumb to this temptation. Man has never been so busy in his lifetime like it is today in this era of the high tech trends, new developments and discoveries. In short, don't be lazy to backup.

TRASH - Know which files to keep and not to keep. You need to do this to keep your backup process as short and as efficient as possible. It also saves you valuable resources like hard disk space and backup mediums. Backup only what you need. Keep out the trash and dump it. In short, don't sweat with the trash.

INTUITION - Have faith in your backup results. Believe that what you are doing is for your own good later on. Like vitamins that keep your body healthy, backups keeps your mind away from stress and worries. A good working backup will make you smile even on the worst of times because you are insured by your patience. In short, believe in good results.

AUTOMATE - Look for alternatives to traditional backup process that can make your life simpler. There are several technologies and softwares you can use now to generate the fastest and safest backup files you will need to restore in case of emergency without you lifting a finger. Automation is king in this lazy man's world. In short, be efficient.

LIBERATE - Free yourself from worries and anxiety of theunexpected. A death sentence that can be prevented will not kill you. So think about what you can do more (like sleepingmore at night) than to think about what harm may come. With your own backup systems established, you can retire at night calmly knowing the next day, if you don't see your websites as you should, you know you can pubish it back within the day even if your webhost cannot recover it for you. In short, relax and enjoy life to the max.

SECURITY - Nothing beats the feeling of being secured. This is the reason why the insurance businesses have flourished over the years. But more importantly, your commitment to backup your files will not only save you from stress, humiliation, frustration, anger and guilt, but also lift your spirit and confidence because you know at the end of the day, your self reliance is well worth it.

And that, my friend, is a great and wonderful feeling.

Koobface virus

Recently I got an email from someone i don't know which tells me that I got a message in Friendster. I read that message and this is it's content.

Your behavior looks pretty shocking to me.
http://www.geocities.com/mbsnhwqmo/

When I clicked that link, I was redirected to other website http://60.53.68.219:7777/?ch=&ea= which contains a video, like a youtube. This website suggest me to download a file to play the video. My anti virus has detected this file a koobface virus.

This is the screenshot of the website
Free Image Hosting at www.ImageShack.us

This virus has known as a facebook virus. The spreading technique almost the same, but with other social network like Friendster. Try to fool someone to play the video and install the file.

Be carefull if you get message which almost the same with this.

With this article, I hope that we can be more carefully not too easily click a link or download a file from other people, even we know that people.

Best regards,

Deny Sutani