Trick of Positioning the Containers of JFrame

Many developers want their own Layout Manager with user-defined so JAVA has provided a separate method for the every container of JFrame Component and that method is setBounds(). This method helps the developers to position the container as per their need .

About SetBounds() method:

This method consists four parameter

  Syntax:
     xxx.setBounds(int x_axis, int y_axis, int width, int height);

We can arrange the containers with the help of this method easily.

A example of this method is shown below:

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.Dimension;

public class LoginPanel {

    public LoginPanel() {

    }

    public static void main (String[] args) {
    	JFrame frame = new JFrame();

    	frame.setLayout(null);

    		//For Positioning the Containers 

    	//Labeling
    	JLabel label = new JLabel("WELCOME TO"+
				"LOGIN PANEL", JLabel.CENTER);
    	JLabel user = new JLabel("UserName:\t");
       	JLabel pass = new JLabel("Password:\t");

    	//Some features of SETBOUNDS() Methods
    	//setBounds(x-axis, y-axis, width, height);
    	label.setBounds(150,10,220,20);
    	user.setBounds(150,50,100,50);
    	pass.setBounds(150,90,100,50);	

    	//TextField
    	JTextField userField = new JTextField();
    	JPasswordField passField = new JPasswordField();

    	//Some of the features of SETBOUNDS() Methods
    	//setBounds(x-axis, y-axis, width, height);
    	userField.setBounds(250,65,80,20);
    	passField.setBounds(250,105,80,20);

    	//Button
    	JButton but1 = new JButton("Submit");

    	//setBounds(x-axis, y-axis, width, height);
    	but1.setBounds(200,150,100,20);

    	//adding containers to JFRAME
    	frame.getContentPane().add(label);
    	frame.getContentPane().add(user);
    	frame.getContentPane().add(userField);
    	frame.getContentPane().add(pass);
    	frame.getContentPane().add(passField);
    	frame.getContentPane().add(but1);

    	//features of JFrame
    	//Although these can be defined
		//before the containers.
    	//We defined at last
    	 	frame.setVisible(true);
    	 	frame.setSize(500,300);

	}	

}

And the output must be like this:

Login Panel Output

Login Panel Output

JNode (Open Source Project)

JNode is the open-source project for making a Java Platform OS(Operating System).
This project had take a exclusive track of making all the software in Java in itself.
As Java Virtual Machine(JVM) only accepts bytecode so the Compiler used to develop native binaries out. In this way, nearly the entire system is able of being written in the JAVA programming Language.

Ewout Prangsma firstly started work of developing the Java Bootable System(JBS) during 1995 .He had caught special feature of Java. In his mind he himself imagined a system that was not only a VM, but a complete runtime environment that does not need any other form of operating system. So is had to be a light weight and most important flexible system. The author was not satisfied with the C and assembly language required and head towards on to a new attempt called JBS2.

Jnode uses only two languages i.e. Java and Assembly Language. This system presently understands the FAT,NTFS,ext2 and ISO 9660 file system. It also has a GUI(Graphical User Interface) with USB peripherals and TCP/IP network protocol. It can be boot from CD or run in any popular emulator. It uses GNU Classpath Java Library and can run any Java Programs.

The latest version of JNode can be found in :

http://www.jnode.org/download_latest

For more Detail : http://www.jnode.org

Some of the System Properties of Java

If we want to programmatically determine what version of the Java Runtime Environment

(JRE) is being used to execute a given application then, we can get the version via the following code illustrates:

//IN WINDOWS PLATFORM

String ver = System.getProperty("java.version"));
System.out.println("This program is running under JRE version " + ver);

if (ver.startsWith("1.5")) {
// Pseudocode.
do something appropriate for newer versions of Java ...
}

else {
// Pseudocode.

do something the pre-5.0 way ...
}

Some of the java System Properties based on JDK 1.5 are given as follows:


Key Description of Associated Value

java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temporary file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator (/ on Unix)
path.separator Path separator (: on Unix)
line.separator Line separator (\n on Unix)
user.name User’s account name
user.home User’s home directory
user.dir User’s current working directory

The following table describes some of the most important system properties BASED on JDK 1.6


Key Description of Associated Value

"file.separator" Character that separates components of a file path. This is
/” on UNIX and “\” on
Windows.
"java.class.path" Path used to find directories and JAR archives containing class files.
Elements of the class path are separated by a platform-specific character specified in the path.separator property.
"java.home" Installation directory for Java Runtime Environment (JRE)
"java.vendor" JRE vendor name
"java.vendor.url" JRE vender URL
"java.version" JRE version number
"line.separator" Sequence used by operating system to separate lines in
text files
"os.arch" Operating system architecture
"os.name" Operating system name
"os.version" Operating system version
"path.separator" Path separator character used in java.class.path
"user.dir" User working directory
"user.home" User home directory
"user.name" User account name

Java Software Development Kit Installation

First of all if you have already java then uninstall that java and download Java Sdk from Sun Microsystem :
For download: jdk 1.6
Then choose your appropriate Operation System and download and Install the *.EXE program

This is one of the tough point for  beginner to install java Beginner.

Some of the steps to maintain Path of Java compiler are given as follows:

STEP 1: Right click on My Computer and Go properties.

STEP 2: Dialogue  Box Appears (given in fig 1.1) Go to Advance Tab > Environment Variables..

Fig 1.1

Fig 1.1 A Dialogue Box of Advance Tab

STEP 3: Now in New Dialogue box (given in fig.1.2 )  You can click on New Tab for creating new variable Read more »

Ternary Operation


TernaryExpression ::= BooleanExpression ? Expression1 : Expression2

Object Disposal

Objects are means to understanding OO(Object Oriented) technology. Objects are

everything which we see around our surroundings on Real World.

For eg. Cat, Dog, Computer, Radio.etc and every object has their own functions .

The objects can be created and destroyed as per our need; in the same

way JAVA also have a feature of Object disposal. Objects can be disposed

when they are not in use in future.

What are raw materials ?

-   The data or any object which are available for an object to use when it is responding to a service

demand by executing one of its methods.

Some Object disposal conditions:

  • Simple data or any object references that has been encapsulated as attributes with
    in the object itself.
  • Simple data or any object references that are passed in as arguments in the
    method signature.
  • Data that is made available globally to the application as public static attributes
    of some other class.
  • Data that can be requested from any of the objects that this object has a handle on.

This type of object is mostly used for the quick referencing so most of the experienced programmers

used these type of object for convient in code and to quick load of the application. It creates the

object for some duration only.

Hardest Programming Language

In my view the toughest programming language is C# and JAVA cuz they have very vast library and their code are tough enough.

Post comment according to your opinion about this topic:

Java’s Print similarities to C

As we know that java is made by the C programming. The java has many common features to C language. While we wants to print in java we usually use the following code.

System.out.println(statement1);
or
System.out.print(statement2);

But there is also the feature of printf in java which we used to do in C programming:

Syntax:

//In C language
printf("format_string", comma_separated_list_of_expressions);
 Read more »