Wednesday 11 July 2012

(July 3' 2012 - July 10' 2012)

After going through so many websites and a huge search manually, I finally had chosen a topic for my project. Yes, finally..!! I decided to code for a Client- Server Chat Application. 
        After having learnt the graphical aspects of java, i began with JTextfields, JButtons , JLabels, JTextAreas, etc etc and started designing the project. It took me about 2-3 days to complete the basic architectural structure of the project.

                     The difficult part was yet to begin..! My technical trainer told me, that i need to know some topics of advanced Java (apart from my core Java course) in order to complete this project. I was a bit frightened , learning the time duration that i had was very little. But within this time, i got to know that vacations were extended , so i again started with my project with full zeal and by this time my 4th semester result was also out and thankfully to God, i cleared the 2nd year of my degree too.
                   Coming back to project discussion..!! So the toughest part regarding this project was the Socket Programming. After inter-linking all the classes to the main class, i began working with socket programming. Though it was quite tough, but in the end, all efforts proved to be fruitful .I cant explain the feeling that i went through when i saw that messages were actually getting transferred from client to server and vice-versa.
             Since now i am almost done with the basic part (excluding improvements to make it more appealing), so here i am posting some snapshots of how this project looks .













































Well, thats the happy ending of this memorable learning experience . !! 

Monday 2 July 2012

Monday (July 2' 2012)

These being the last 2 days for our theory classes, we were taught about Database Management. We were briefly introduced with MS Access and SQL. SQL stands for Structured Query Language and is a standard language for accessing databases. Now we know how to handle or manipulate data in MYSQL , SQL Server, ACCESS, etc.
           A database most often contains one or more tables. Several commands are used to handle queries or to insert, delete or show the entries in a table.

Example:-

The INSERT INTO Statement

The INSERT INTO statement is used to insert a new row in a table.

SQL INSERT INTO Syntax-


INSERT INTO table_name VALUES (value1, value2, value3,...)

and the MySQL Command Line Client looks like ->

















Sunday 1 July 2012

(June 27' 2012 & June 30' 2012)

Continuing with the Graphical aspects, now we were taught about Swings. Swing is built on the foundation of the AWT. It has lightweight components and a pluggable look and feel. A Swing GUI consists of two key items: components and containers. The main package is javax.swing. This package must be imported into any program that uses Swing. It  the classes that implement the basic Swing components, such as push buttons, labels, and check boxes.


Example: demonstrating how to change font of JTextField's text using Java Swing JTextField class.


import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.JApplet;
import javax.swing.JTextField;

public class TextFieldTest extends JApplet{
      
        public void init(){
                this.getContentPane().setLayout(new FlowLayout());
                JTextField field = new JTextField("JTextField Change Font",30);
              
                Font font = new Font("Courier", Font.BOLD,12);
                field.setFont(font);

                add(field);
        }
}


OUTPUT:- 





Tuesday 26 June 2012

(June 25' 2012 & June 26' 2012)

We were taught about Applets these days. I was quite bored  writing the codes and seeing the  output on the console and dancing with joy that the code actually worked, but now began the interesting part when we started with the graphical side of java.
                An applet is a special kind of Java program that is designed to be transmitted over the Internet and automatically executed by a Java-compatible web browser. Applets use the AWT.
     Applet provides all necessary support for applet execution, such as starting and stopping. It also provides methods that load and display images, and methods that load and play audio clips.

      Example :  A simple example that shows colored text using java applet and color classes.

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;


public class ColorHello extends Applet{
      
        public void paint(Graphics g){
              
                g.setColor(Color.blue);
             
                g.drawString("Hello World...",30,180);
        }
}


OUTPUT:-








Friday 22 June 2012

(June 18' 2012 - June 22' 2012)

First 3 days of this week we learned about Generics & Collections and on 21st-22nd, we had tests and brush-up sessions.TheA collection is a group of data manipulate as a single object. term generics means parametrized types. Using generics, it is possible to create
a single class that automatically works with different types of data.

Example:

import java.util.ArrayList;
import java.util.List;
public class GenericList {
   
public static void main(String[] args) {
     
List list=new ArrayList();
         list
.add("aaa");
         list
.add("bbb");
         list
.add("fff");
         list
.add("ccc");
         list
.add("ddd");
         
System.out.println(list);
   
}
}
 
Output:

[aaa, bbb, fff, ccc, ddd]


Collections A collection is a group of data manipulate as a single object. These are similar to C++'s Standard Template Library (STL) and contain only Objects (reference types).

Example:-

import java.util.HashSet;
import java.util.Collections;

public class Collection{

  public static void main(String[] args) {
 
    HashSet hashSet = new HashSet();
  
    hashSet.add(new Long("92"));
    hashSet.add(new Long("42"));
    hashSet.add(new Long("23"));
    hashSet.add(new Long("32"));
  
    Object obj = Collections.min(hashSet);
  
    System.out.println("Minimum Element of Java HashSet is : " + obj);
  }
}


OUTPUT:

Minimum Element of Java HashSet is : 23





Friday 15 June 2012

(June 14' 2012 - June 15' 2012)

We discussed the concept of Threads these 2 days. Java uses threads to enable the entire environment to be asynchronous. This helps reduce inefficiency by preventing the waste of CPU cycles. Also threads exist in several states such as running, ready to run, suspended, resumed, blocked.

          Creating a Thread: This can be do.ne by instantiating an object of type Thread. For this we can,
i) Implement the Runnable interface ,or
ii) Extend the Thread class itself.

Example:

          public class Threads{
  public static void main(String[] args){
  Thread th = new Thread();
  System.out.println("Numbers are printing line by line after 2 seconds : ");
  try{
  for(int i = 1;i <= 5;i++)
    {
  System.out.println(i);
  th.sleep(2000);
  }
  }
  catch(InterruptedException e){
    System.out.println("Thread interrupted!");
  e.printStackTrace();
  }
  }
}


OUTPUT-

Numbers are printing line by line after 2 seconds :
1
2
3
4

5



   Similarly, our program can spawn as many threads as it needs.

Wednesday 13 June 2012

(June 9' 2012 - June 13' 2012)

All these days, we had tests and brush-up sessions. Our trainers focused on making strong our previously done Java concepts. I also had decided about my project by now and have started researching about it. We will be starting new concepts from tomorrow onwards and hopefully will start working on my project this week..!!