Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Determine left right and middle mouse button click

Sunday, 24 April 2011
if(evt.getButton() == java.awt.event.MouseEvent.BUTTON3)
{
}

MOuse right click
-right button1
-left button2

Descending order

SQL order by

SELECT store_name, Sales, Date
FROM Store_Information
ORDER BY Sales DESC
Record order descending


substr(string,start,length)

string Required. Specifies the string to return a part of
start Required. Specifies where to start in the string

A positive number - Start at a specified position in the string
A negative number - Start at a specified position from the end of the string
0 - Start at the first character in string

length Optional. Specifies the length of the returned string. Default is to the end

of the string.

A positive number - The length to be returned from the start parameter
Negative number - The length to be returned from the end of the strin

Sort Table Content

Thursday, 7 April 2011
if(evt.getClickCount() == 2) {
            if(jt.getSelectedColumn() < 0) return ;
            else genui.sortAllRowsBy(jt,jt.getSelectedColumn(),true);
            adjustemployeecolumn();
        }

private void adjustemployeecolumn()
    {
         genui.settablecol(jt.getColumnModel().getColumn(0),1);
            genui.settablecol(jt.getColumnModel().getColumn(1),90);
            genui.settablecol(jt.getColumnModel().getColumn(2),190);
            genui.settablecol(jt.getColumnModel().getColumn(3),200);
            genui.settablecol(jt.getColumnModel().getColumn(4),200);
            genui.settablecol(jt.getColumnModel().getColumn(5),190);
            genui.settablecol(jt.getColumnModel().getColumn(6),90);
    }

Date- Set Today's Date to ComboBox

Friday, 1 April 2011
import java.text.SimpleDateFormat;
import java.util.Calendar;


public Calendar cal1 = Calendar.getInstance();
public Calendar cal2 = Calendar.getInstance();


Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String datetoday=dateFormat.format(calendar.getTime());
cmbyear.setSelectedItem(genui.getyeardigit(datetoday));
cmbmonth.setSelectedItem((String) genui.getmonthdigit(datetoday));            //read from database
cmbday.setSelectedItem((String) genui.getdaydigit(datetoday));

set minimum to the java table

Thursday, 31 March 2011
jt.getColumnModel().getColumn(1).setMinWidth(10);
jt.getColumnModel().getColumn(2).setMinWidth(10);
jt.getColumnModel().getColumn(3).setMinWidth(10);
jt.getColumnModel().getColumn(4).setMinWidth(10);
jt.getColumnModel().getColumn(5).setMinWidth(10);
jt.getColumnModel().getColumn(6).setMinWidth(10);

set minimum to the java table

Open A form in the middle of the Screen

Tuesday, 29 March 2011
Before you start adding components to the JFrame you might want to make the main application window open in the center of the screen and give the application a title in the main window title bar. To center the main application window do the following:

    Right-click the JFrame and choose Properties
    Click on the Code tab (Figure 5)
    For Form Size Policy choose Generate Resize Code
    Be sure Generate Center is checked
    Click the Close button