Sunday, April 27, 2008

Make a beep!


A reader asked how to get his program to make a BEEP whenever a user clicks a button. The simplest way of doing this is to import the java.awt.Toolkit library and then add the following code to your application :

Toolkit beeper = Toolkit.getDefaultToolkit();

Until next time.

Saturday, April 26, 2008

Center a JFrame or JDialog on a parent window or the desktop.

I often get asked how to center a JFrame or JDialog on the desktop or another frame. It's really a quite simple operation. All you need is the following command :


This command will set the frame object as CENTERED on the main desktop of the current operating system. If you replace the null with the name of another object, like a parent frame in a JDialog window you can center the JDialog on a JFrame.


Friday, April 25, 2008


Welcome to the Java for Kids blog!

This blog is dedicated to providing practical examples, source code and explanations for students studying the Java programming language.

Use our resources to help you do your homework, school work or projects and assignments. The blog content is aimed at grade 10 to 12 students and is based on the local school curriculum. If you are looking for Afrikaans resources, consider visiting our Afrikaans-orientated website at JavaK.

Download our free Java and SQL tutorial from if you are a beginner SQL programmer.