Sunday, September 26, 2010

Make the ENTER key act like the TAB key In java.

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;


To make  the ENTER key act like the TAB key In java.


Changing the Focus When Pressing the Enter Key same as Tab key.
Swing Java code is.........................as follows.



import 
javax.swing.JTextField;

class MyTextField extends JTextField {
  MyTextField(int len) {
    super(len);
    addKeyListener(new KeyAdapter() {
      public void keyPressed(KeyEvent evt) {
        int key = evt.getKeyCode();
        if (key == KeyEvent.VK_ENTER)
          transferFocus();
      }
    });
  }
}

Friday, September 24, 2010

SQl Server Case in Query Exmple

select distinct rp.RoleId, ri.Role,mo.Operation, rp.OPerationId,
case rp.Adds when 1 then 'Yes' else 'on' End as AllowAdd,
case rp.Views when 1 then 'Yes' else 'on' End as ViewAllow,
case rp.Deletes when 1 then 'Yes' else 'on' End as DeleteAllow,
case rp.Disapprove when 1 then 'Yes' else 'on' End as DisapproveAllow,
case rp.Approve when 1 then 'Yes' else 'on' End as ApprovedAllow
from RolePrivilege rp, RoleInfo ri, ModuleOperation mo
where rp.RoleID=ri.RoleID and rp.OPerationID=mo.OperationID and ri.RoleId=2;