How to set shortcut keys to menu-items in java easy way:
JMenuItem mi=new JMenuItem("Item");
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK));
JMenu menu=new JMenu("Menu");
menu.add(mi);
where, VK_I=the key which is to used as shortcut key
CTRL_MASK=which key is to pressed with shortcut key
Java Database Connectivity to MySQL Server Database easyway:
MySQL server database connectivity a connector , that can be download from internet. A jar file is there to download as JConnector in various versions.I use mysql-connector-java-5.1.8-bin.jar. Extract that jar file where your database connectivity program saved. This jar file contains drivers that are required to connect to MySQL database.Database connectivity code is as follows:
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost/ database_name","root","MySQL root password");
Click here: Example of java MySQL database connectivity
How to create a jar file of application created in java :
Step 1:- Copy all the class files & file & folders required for application in folder
Step 2:- Setting environmental variable
Open command prompt. Go to folder where your application exists.
Set environmental variable by executing following command
set path="c:/program files/ java/ jdk 1.5/ bin";
where path string is path of jdk/bin installed in your PC
Step 3:- Creating a jar file:
Execute following command at command prompt.
jar cvf application_name.jar *.*
press enter. Your jar file is created.
Step 4:- Now open that jar file with winrar.
Open manifest.mf file in notepad. manifest.mf file exists in folder META-INF folder. Write following line in last of file
Main-Class: Name of first opening frame main class file of your application without .class extension without extension, for example password screen.
Example, Main-Class: password_screen
save changes to file.
Double click on jar file. See what happens.
This comment has been removed by the author.
ReplyDeleteHey, gamblingdada! who are u? What u posted?
DeleteThis comment has been removed by a blog administrator.
ReplyDelete