Wednesday, October 13, 2010

Listening to JMenuItem Events with a MenuKeyListener


Listening to JMenuItem Events with a MenuKeyListener
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;

public class ContructMenuMenuKeyListener {
  public static void main(final String args[]) {
    JFrame frame = new JFrame("MenuSample Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar menuBar = new JMenuBar();

    // File Menu, F - Mnemonic
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    // File->New, N - Mnemonic
    JMenuItem newMenuItem = new JMenuItem("asdf");
    fileMenu.add(newMenuItem);
   
    newMenuItem.addMenuKeyListener(new MenuKeyListener(){

      public void menuKeyTyped(MenuKeyEvent e) {
       System.out.println("KeyTyped");
      }

      public void menuKeyPressed(MenuKeyEvent e) {
        System.out.println("KeyPressed");
      }

      public void menuKeyReleased(MenuKeyEvent e) {
        System.out.println("KeyReleased");
      }});
   

    frame.setJMenuBar(menuBar);
    frame.setSize(350, 250);
    frame.setVisible(true);
  }
}

Sunday, October 10, 2010

Throw exception through main method in java

public class MainClass{
public static void main(String[] arg) throws Throwable{
try{
throw new Throwable();
 }
catch(Exception e)
{
System.err.println("caught in main");
}
}
}

Common JAR file operations

To create a JAR file                    jar cf jar-file input-file(s)
To view the contents of a JAR file         jar tf jar-file
To extract the contents of a JAR file     jar xf jar-file
To extract specific files from a JAR file jar xf jar-file archived-file(s)

Saturday, October 9, 2010

The javap Tool

The javap command displays information about the methods, variables, and parameters present in a class file.
The output of the javap tool depends on the options used. If you do not specify any options while using the jap tool, the javap tool prints the package, protected, and public fields and methods of the classes passed to the tool.

JDK Utilities

ToolFunction
javacThe Java compiler. Converts Java source code into bytecodes.
javaThe Java interpreter. Executes Java application bytecodes directly from class files.
appletviewerA Java interpreter that executes Java applet classes hosted by HTML files.
javadocCreates HTML documentation based on Java source code and the comments it contains.
rmicCreates class files that support Remote Method Invocation (RMI).
rmiregistryRegistry used to gain access to RMI objects on a specific machine.
rmidActivation system daemon for RMI object registration and activation.
native2asciiSpecial program used to convert between standard Latin-1 Unicode characters and other international encoding schemes.
jarJava Archive (JAR) file generator. JAR files allow multiple Java classes and resources to be distributed in one compressed file.
keytoolUsed for security key generation and management.
jarsignerImplements digital signing of JAR and class files. Allows applets to be certified by trusted authorities.
policytoolAllows user-installation-level security policy configuration.

Thursday, July 15, 2010

B-Tree.

The Data Base server uses a B-Tree structure to organize index information
B-Tree has following type of index pages or nodes
1.Root node:-A root node contain node pointers to branch nodes which can be only one.

2.Branch nodes:-A branch nodes contains pointers to leaf node or other branch nodes
wich can be two or more.

3.Leaf nodes:-A leaf node contain index items and horizontal pointers to other leaf nodes
witch can be many.

Tuesday, July 13, 2010

உன்னைத் தேடு:

அன்பில் அமைதியைத் தேடு
இளமையில் கல்வியைத் தேடு
ஒற்றுமையில் பலத்தைத் தேடு
கோபத்தில் பொறுமையைத் தேடு!

பயணத்தில் விவேகத்தைத் தேடு
சிந்தனையில் அறிவைத் தேடு
சிரிப்பில் ஆரோக்கியத்தைத் தேடு
தோல்வியில் முயற்சியைத் தேடு!

நட்பில் நம்பிக்கையைத் தேடு
கற்பனையில் கவிதையைத் தேடு
வேதனையில் உறுதியைத் தேடு
வாழ்க்கையில் நீ உன்னைத் தேடு!