Java Tutorial

by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing
 
 
 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing

The FlowLayout is the simplest manager. The components are arranged from left to right in the order in which they appear, i.e., in the order they are added. When there is no more space on a line, another line is created, resembling a text editor. This process is automatically done according to the container size.

 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing

The PasswordField is a special kind of textfield. It is a single line textfield used for accepting passwords without displaying the characters typed in. Each typed character is represented by an echo character typically an astriek (*). To create a PasswordField component, instantiate the JpasswordField class.

 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing

The flow layout manager is the simplest of all the layout managers. It positions the components in the order they are added to the container. It places the components from left to right, that is, horizontally. Once a row gets completely filled with components then the remaining components are placed in the next row. It is the default layout manager for Applet and Panel. Each component is evenly separated from its neighboring components by leaving a small space not only from above and below it, but also from left and right.

 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Swing

The most common use of inner classes is with event handling. An inner class can be used to implement a particular listener interface or to subclass a particular adapter. This has the benefit of separating out the control aspect of the interface from the display elements. It also means that the event handler inner class can inherit from a different class to the encompassing class.

 
by Dinesh Thakur Category: Swing
 
by Dinesh Thakur Category: Java Methods

In this program, user is asked a number to enter which is stored in integer form in variable n. The value entered is say 1023.Now, this value of variable n is passed to parameter x by invoking revers() method. In revers() method, x is divided by 10 and the remainder is displayed (% returns remainder). When 1023 is divided by 10, the remainder will be 3 which is displayed on the screen. Then, again revers() is invoked with value 102/10 i.e. with 102 (because the output of dividing two integers is also an integer). 102 is assigned to variable x. Again, 102 is divided by 10 and the remainder is displayed. The remainder this time will be 2 which is displayed. Again revers() method is invoked with 10/10 i.e. which 1. And the process continues until value of x becomes 0.

 
by Dinesh Thakur Category: Java Methods

There are two ways of passing arguments to a method (function/subroutine):

1. Call by Value

This method copies the value of an argument into the formal parameter of the method. Therefore, changes made to the parameter of the method are limited to that method only and there is no impact of changes on the argument. That is, when control returns back to the caller method, earlier values of the arguments will be seen.

 
by Dinesh Thakur Category: Java Methods

Recursion occurs when a function calls itself in its own body. That is, in the body of the function definition there is a call to itself. When the function calls itself in its body, it results in an infinite loop. So, there has to be an exit condition in every recursive program.

 


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.