Java Tutorial

Introduction to javax.swing Library. A Simple Notepad Application. Part 2

Submitted by pavel7_7_7 on
This is the second part of the A Simple Notepad Application tutorial. In this article you will see, how all the functions of the text editor are implemented. So, we continue our work on the text editor. We have the graphical user interface. First step to implement the functionality is to add shortcut keys to every menu item. We will ise for this KeyAdapter.

Introduction to javax.swing Library. A Simple Notepad Application. Part 1

Submitted by pavel7_7_7 on
In this article I'll describe how to create a simple Notepad application using javax.swing library. Now, you know how to create java projects in Eclipse. So, we will create a new project, called coolReader. First of all, I'll show you the structure of the project: structure So, the project consists of 3 classes and a set of images, used to create some buttons. Now,we wil speak about coolReader class. This class is the class, that has the full implementation of the GUI and event handling.

Introduction to javax.swing Library

Submitted by pavel7_7_7 on
In this tutorial you will find a step by step guide about creating your first Java Application with Graphical User Interface using Eclipse IDE. Swing library is one of the most used libraries to create applications with Graphical User Interface (GUI). This library has a large set of different GUI components. We will start from the simplest application - "Hello World!" application.
  1. Open the Eclipse IDE. Choose "File" -> "New" -> "Project" from menu.

Styling Java Buttons & Labels with HTML tags

Submitted by mehfuza on

Introduction:

Java buttons and labels support using different HTML (Hyper Text Markup Language) tags. HTML is Web page development language where as Java is Programming language but still Java executes the HTML tags and displays the output according to the HTML tags. These tags can be used to insert new line on the button or labels or styling the text on the buttons and labels. Text Area does not support executing HTML tags it displays the tags as it is. Buttons and label support following HTML tags.

Tags Supported by Labels and Buttons

1.

Cursor and Combo Box Demo in Java

Submitted by mehfuza on

Introduction:

In this tutorial we will see changing cursor when it is selected from Combo Box in Java. You will learn about cursor as well as JComboBox. The position of the mouse is represented on the computer's screen by a small image called a cursor. It has a hot spot, which is a Point that specifies the pixel within the image that corresponds to the exact point on the screen where the mouse is pointing. The Cursor class has many predefined cursor which can be used with Cursor.getPredefinedCursor(code) method. Where code represent type of cursor.

Creating Executable Program in Java

Submitted by mehfuza on
Executable software can be created using JAR(Java Archive) utility. Once you create jar file of the program it can run on any machine having JRE(Java Runtime Environment ) installed. JAR file should contain the .class files and resource such images, audio or any other files required. Including only .class files makes the code private. It can also include .java files, the source code of the program. Following are the commands to be run at Command Prompt or Terminal in Linux. Step 1: Compiling the Java Programs First compile all the Java programs of an application.

Simple Editor in Java

Submitted by mehfuza on

Introduction

This simple editor has only one menu with New, Open, Save, Exit option. It requires JMenuBar, JMenu, JMenuItem, ActionListener, File related classes. This tutorial demonstrate creation of menu and reading and writing the files. Once user clicks on open menu then Open dialog box is displayed and File is displayed in the display area. This simple editor can be created easily with following steps. File reading and writing part is similar to previous tutorial.

Implementation

Step 1: Designing the Menu The class is application so it extends JFrame.

Simple Web Browser in Java

Submitted by mehfuza on
In this tutorial we will see how to create a simple web browser. It contains an address bar where a user can type the address and a go button which when clicked loads the web page. For displaying the web pages we require JEditor Pane and HyperlinkListener is required to respond when the user clicks on a link in the document. Following are the steps for creating the web browser. Step 1: Defining the constructor of the class The main class extends the JPanel.

Reading from and Writing to a Text File in Java

Submitted by mehfuza on
Introduction: This tutorial demonstrate the method of reading from and writing to a text file in Java. Java has two type of files: Binary and Text. Text file is processed as a sequence of characters where as Binary file is processed a sequence of bytes. This application has 4 JButtons for reading, writing, exiting, and clearing the Display Area. Also It has a display area where we can type the data to be written to text and in the same area content from file are displayed. Step 1: Creating GUI Components Create the four buttons, label, text area and text field.

Creating Sleepy Face in Java

Submitted by mehfuza on
In this tutorial we will learn to create a simple face(only eyes) which change when sleep button or wakeup button is clicked. This Application has two JButtons and a Panel for displaying the face. This Application handles Action Events for the buttons. In all we will create three class to make the design simple and clear.

Part 1: Creating a Class FacePanel for drawing face

Step 1: This class is used to draw the face based on whether the face is awake or asleep. For that we require a boolean variable awake which is set false initialy.