Posts

Creating a simple window application using Java Swing

Image
 A simple window application using Java Swing Swing is a toolkit API that makes it easy to build user interfaces using Java. The Swing API has about 18 public packages containing various Swing components which can enable us to create all sorts of GUI features. The interface components work the same on most platforms. In this article, we will be setting up a basic GUI application window. This will enable one to build more complex applications in the future. Before proceeding ahead, let us try to wrap our heads around the concept of packages in Java. Packages Relationship between a package and its underlying classes The above-given diagram illustrates what a package is and how its child classes can be accessed from outside. A package can be seen as a directory (or a folder) that contains some source files defining useful classes. The diagram describes the way to import the classes from a package. Now to import the Swing API classes you must add the following line to your code: impor...

An implementation of a linked list in Java

Image
 Linked List A linked list is a data structure consisting of nodes. Each node has a variable pointing to the node next to it. This makes the linked list a way of storing data in a sequence. This may sound similar to an array. It is. However, an array has a fixed size, making insertion a little trickier. With a linked list, the number of nodes can change to however many we want and insertion is as easy as changing the pointing variable of the node before which you would like to insert the new node.  Linked lists can also be used to implement more complex data structures such as trees and graphs.  An interest in the data structure of linked lists in general and a new introduction to the Java programming language sparked my interest in implementing this in Java. Having done some projects in C++, I had already begun thinking up a way to do this in C++. But doing it with Java, presented some new learnings to me, mainly concerned with the structure of the program and the way Ja...

Using a CSV file from C++ program | Flight booking system

Image
Using a CSV file to store data from a C++ program I used objects to store each flight's data in a previous project. This made the program hold the data in the random access memory. This can pose a problem as it is not a permanent way of storing the data and will be erased once the program ends. To counter this, I initially thought of using a database with C++. I sought help with this online and was told about using a CSV file before using a database. A CSV file is a file format that stands for Comma Separated Values. This file can be used to represent rows in the form of lines and column data as values in each line that lie in the same position in their respective line. This way CSV files can be used to represent tabular data. Having said all that, we should look at how we can create a CSV file. Creating a CSV file There are two ways of creating a CSV file. You can either use a text editor such as Notepad in Windows, or you can use a sheets application such as MS Excel in Windows. ...