Creating simple Database Application in Java

Create Following Table : Table Name :studentdetails { stud_id Text, stud_name Text, stud_add Memo, stud_mob Text, stud_email stud_email, stud_dob Text, stud_academicyr Text, stud_course Text } After Database creation start designing GUI For Application using Netbeans which look like Following use jTabbedPane for Tabbed Appearance of Application. Create DSN : In Windows follow Following Steps 1 Goto … Continue reading

KeyListener in java

import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet code =”Keys” Height=”500″ Width=”500″ > </applet> */ public class Keys extends Applet implements KeyListener { int r; public void init() { r=100; addKeyListener(this); } public void keyPressed(KeyEvent ke) { int key=ke.getKeyCode(); switch(key) { case KeyEvent.VK_L: r=r+10; repaint();break; case KeyEvent.VK_B: r=r+10; repaint();break; case KeyEvent.VK_D: r=r-10; repaint();break; case KeyEvent.VK_S: … Continue reading

Count Vowels in java using ASCII code of vowels

import java.io.*; public class CountVowels{ public static void main(String args[])throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println(“Enter the String:”); String text = br.readLine(); int count = 0,blank=0; for (int i = 0; i < text.length(); i++) { int c = text.charAt(i); if ((c==97||c==65 )||( c==101||c==69 )||(c==105||c==73)||(c==111||c==79 )||(c==117||c==85)) { count++; } if(c==32) { blank++; … Continue reading

Mouse Events in java

import java.awt.*; import java.awt.event.*; import javax.swing.*; class MouseEvents extends JFrame implements MouseListener, MouseMotionListener { String str=””; JTextArea ta; Container c; int x,y; MouseEvents() { c=getContentPane(); c.setLayout(new FlowLayout()); ta=new JTextArea(“Click the mouse or move it”,8,20); ta.setFont(new Font(“Lucida Fax”,Font.BOLD, 20)); c.add(ta); ta.addMouseListener(this); ta.addMouseMotionListener(this); } public void mouseClicked(MouseEvent me) { int i=me.getButton(); if(i==1) str+=”Clicked Button:=left”; if(i==2) str+=”Clicked Button:=Middle”; … Continue reading

color chooser example in java

import java.awt.*; import java.awt.event.*; import javax.swing.*; class ColorPallete extends JFrame implements ActionListener { JButton b; Container c; JTextArea ta; ColorPallete() { c=getContentPane(); c.setLayout(new FlowLayout()); b=new JButton(“Select a color”); c.add(b); ta=new JTextArea(1,5); ta.setText(“Amit Dhuri”); ta.setFont(new Font(“Lucida Fax”, Font.BOLD, 25)); c.add(ta); b.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent ae) { Color selectedcolor=null; Color color=JColorChooser.showDialog(this, “Select a color”, selectedcolor); … Continue reading