It's all about Java: Java basics
Showing posts with label Java basics. Show all posts
Showing posts with label Java basics. Show all posts

Monday, 26 April 2021

Evolution of Java Programming Language

Evolution of Java:

First of all, The Java programming language and it's tools that we currenly using is not what actually expected. This language started as a project to give solutions for embedded devices, mobile phones and other portable peripherals. 

Initially, the Java was called Oak. 


Why it is Oak first..? and Why it transformed to Java..?


The team of five technocrats including Dr. James Gosling and also known as Dr. Java, together working on a project, which expected to give solutions on embedded devices, portable smart devices and TV Set top Boxes etc. at Sun Micro Systems. 

In the process of achieving this solution, at their breaktime, team used to relax with a coffee by having a glimpse on a scenery of Oak tree next to their facility. 

Once the project has come to conclusion and in the process of giving a title to it, they noticed the Oak trees [Always observing them in their break time], they named this programming language as Oak.

Oak Logo


Why it transformed to Java..?

When the first version of Oak is about to release, The trademark search revealed that Oak is already registered for Oak Technologies company. Then, Java was named to this project.

In the previous paragraph, it is told that, "team used to relax with a coffee by having a glimpse on a scenery of Oak trees next to their facility...". When one of the team members asked to barista, [Usually a coffee bar tender is called with that name] about the name of the coffee bean that she/he serves in the break..? The reply was "Coffee is made of Java Beans.."




Immediately the name of the project confirmed to be Java and first version 1.0 is released into the industry in the year 1994. Rest we know, how Java programming language was developed and evolved into the bigger scope like smart phones, Inbuild JRE into web browsers etc.

The Oracle claims that more than 1 billion devices uses JRE and millions of developers uses Java and it's tools every day.

Java Version 16  is released in March 2021.




Few of the Java products are:

  • TV Set top Boxes,
  • Android OS
  • Realtime JVMs
  • Embedded devices
  • Almost all Browsers


Java evolved almost 30 years ago since 1994 from it's first version and almost all devices used Java and it's products directly or indirectly in their daily use. Hope Java continues it's charisma infinity days and will do wonders.


Happy Coding..! :)  





Monday, 29 January 2018

Swing: JFrame usage demo

This post helps in understanding usage of JFrame class with an example


Swing toolkit categorizes components into 2 types. They are:

  • Containers
  • Controls

Containers allows Controls to be arranged on them. JPanel, JFrame and JDialog are few which are frequently used.

Controls are components like Buttons, labels, tables etc. These controls are arranged on containers using different layout managers.

All Swing class names starts with J stands for Java which symbolizes swing is pure java! 

Layout Managers:

Layout manager is responsible for laying out controls on containers according to the business requirement. Example layout managers are BorderLayout, GridLayout, GridBagLayout and FlowLayout.

Few points about JFrame:
  • JFrame is considered as a main window of the application.for almost all swing based applications
  • All other controls and containers are created as child components of JFrame
  • JFrama holds special components like  Menu bar, Tool bar etc  

Example program

1 import javax.swing.JFrame;
2 import javax.swing.SwingUtilities;
3
4 /**
5  *
6  * Simple class to demonstrate JFrame container of swing toolkit
7  *
8  * @author Nagasharath
9  *
10 */
11public class FrameDemo extends JFrame {
12
13 private final String title = "It's all abt java!...  ";
14
15 /**
16 * set properties of the main window. Title, size of frame and position/location
17 */
18 public FrameDemo() {
19 this.setTitle(title);
20 this.setSize(300, 200);
21 this.setLocationRelativeTo(null);
22 initComponents();
23 }
24
25 /**
26 * It is used in future articles for instantiating controls like buttons etc.
27 * left empty for now.
28 */
29 private void initComponents() {
30 }
31
32 public static void main(String[] args) {
33
34 Runnable r = () -> {
35 FrameDemo demo = new FrameDemo();
36 demo.setVisible(true);
37 };
38 SwingUtilities.invokeLater(r);
39 }
40}
41


Line 1: Our class FrameDemo extends JFrame hence gets all benefits that JFrame possess    

Line 20: Sets the width 300 and height 200. How ever frame is re sizable at run time

Line 21:  Puts the frame at the center of the desktop monitor

Line 36: Unless call to setVisible(true), frame can not be seen at all.

Line 38: It is always good practice to call setVisible(true) in invokeLater().

Output on Win 10:

The look and feel we see below  is default which is same on all platforms 

This Look and feel can be changed using UIManager class. We see it in coming posts.  

      
JFrame with title


Popular posts

Atomicity with Java Programming Language

 Atomicity with Java What is Atomicity Atomicity, in computer science, is considered to be a property [ALL-OR-NOTHING], that the state of a ...