Tag: Source Code

Towers of Hanoi Java Program

This Java Program solves the Towers of Hanoi problem for a tower of 10 disks. Ten differently-sized disks are stacked in a pile, in order of decreasing size. There are two other places for piles. The object is to move the pile to the second available place, subject to the rules that only one disk at a time can be moved, and no disk can be piled on top of a smaller disk. The Towers of Hanoi problem is a standard example of recursion.

Read More

Java Swing GUI Example Program

This Java source code is an example of a Graphical User Interface (GUI) with different GUI elements such as TextBox, Buttons, TextArea, Text Area and Labels. It is implemented using Java Swing API which provides a set of “lightweight” (all-Java language) components. This code example extends the functionality of JFrame class to show a JFrame window and Implements ActionListener on buttons to catch the click event on those buttons.

Read More

Java Calculator Program with AWT and Swing Based GUI

This Java source code implements a basic calculator with a graphical user interface (GUI) using AWT and Swing. The program is structured in a way that makes it suitable for novice programmers to understand and learn about GUI development in Java. It serves as an excellent starting point for those looking to explore basic GUI applications and understand the principles of event-driven programming.

Read More

Simple Java Contact Form

The following Java code defines a simple GUI application using Swing. It creates a form with text fields for name and email, a text area for messages, and actions buttons for OK and Cancel operations. Additionally, there is a button to change the background color of the form.

Read More

String Sorting in Java

In this article, we explore different sorting techniques applied to strings in Java. We will look into the implementation of the direct insertion sorting algorithm and more advanced techniques such as the Merge Sort and Quick Sort algorithms. Each approach offers unique advantages by providing Java developers with flexibility in choosing the most suitable method based on the specific requirements of their applications.

Read More

Java Program to Draw Star Shapes

This Java program creates a simple graphical application that draws rows of stars using Java’s Swing library. The program creates a window with rows of stars drawn on it. The Star class defines the shape of a star, the StarPane class handles the drawing logic, and the StarApplet class sets up the main frame for the application. This example showcases basic GUI programming with Swing.

Read More