Monday, July 31, 2017

Review App for Colleges

Please Click here to get the code...



Also contribute to make code even better.....

All News App Android



Please Click here to get the code...



Also contribute to make code even better.....

Android Tambola Game



Plz Click Here to get the code


Also plz contribute to make code even better



Saturday, July 1, 2017

GUI based Database Connectivity

Code:


NearurBank.java


JDBCUSE.java

Bank.java




Please refer to above links and Your Contribution is welcomed.........

Thursday, June 29, 2017

Registration Form JSwing

Code:


import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;

class form {
JFrame fr;
JPanel ptitle,pnam,peml,pmob,ppas,pgen,padr,psub,pall;
JButton btn;
JLabel ltitle,lnam,leml,lmob,lpas,lgen,ladr;
JTextField tnam,teml,tmob;
JTextArea tadr;
JPasswordField tpas;
JRadioButton male,fem;
ButtonGroup bg;
JDialog d;
Customers c=new Customers();

form(){
fr=new JFrame("Nearur Registration");

ptitle=new JPanel();
pnam=new JPanel();
peml=new JPanel();
pmob=new JPanel();
ppas=new JPanel();
pgen=new JPanel();
padr=new JPanel();
psub=new JPanel();
pall=new JPanel();

ltitle =new JLabel("Registration Form");
lnam =new JLabel("Enter Your Full Name:");
leml =new JLabel("Enter Your Email:");
lmob =new JLabel("Enter Your Mobile Number:");
lpas =new JLabel("Enter Your Password:");
lgen =new JLabel("Gender:");
ladr =new JLabel("Enter Your Address:");

tnam=new JTextField(16);
teml=new JTextField(16);
tmob=new JTextField(10);
tadr=new JTextArea(3,20);
tpas=new JPasswordField(16);

btn =new JButton("Submit");

male=new JRadioButton("Male");
fem=new JRadioButton("Female");
bg=new ButtonGroup();


d=new JDialog();
}

void generate() {

ptitle.add(ltitle);

pnam.add(lnam);
pnam.add(tnam);

peml.add(leml);
peml.add(teml);

pmob.add(lmob);
pmob.add(tmob);

ppas.add(lpas);
ppas.add(tpas);

pgen.add(lgen);
bg.add(male);
bg.add(fem);
pgen.add(male);
pgen.add(fem);

padr.add(ladr);
padr.add(tadr);

psub.add(btn);

pall.add(ptitle);
pall.add(pnam);
pall.add(peml);
pall.add(pmob);
pall.add(ppas);
pall.add(pgen);
pall.add(padr);
pall.add(psub);

GridLayout layout = new GridLayout(8, 1);
pall.setLayout(layout);

fr.add(pall);

fr.pack();
fr.setVisible(true);

btn.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
save();
}

});

}
void save() {
c.name=tnam.getText();
c.mobile=Long.parseLong(tmob.getText());
c.password=tpas.getPassword().toString();
c.Address=tadr.getText();
c.email=teml.getText();
if(male.isSelected()) {
c.g='M';
}
else {
c.g='F';
}
File f=new File("C:/Users/mrdis/Desktop","Customers.txt");
FileOutputStream w=null;
ObjectOutputStream oos=null;
try {
w = new FileOutputStream(f);
oos=new ObjectOutputStream(w);
oos.writeObject(c);
} catch (Exception e) {

e.printStackTrace();
}finally {
try {
w.close();
oos.close();
}catch(Exception e) {


}
}


JOptionPane.showMessageDialog(fr,"Successful");
tnam.setText("");
tpas.setText("");
teml.setText("");
tadr.setText("");
tmob.setText("");
bg.clearSelection();
}
}
public class NearurRegistration {

public static void main(String[] args) {
new form().generate();
       
}

}


Output:

Wednesday, June 28, 2017

Notepad Using Java

Code:

package com.nearur;

import java.awt.FileDialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PrinterException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;

class notep{
JFrame fr;
JTextArea a;
JMenuBar mb;
JMenu File,Edit,Format,View,Help;
JMenuItem New,Exit,Open,Save,Cut,Copy,Paste,Print,Delete;
FileDialog d,op;

       notep() {
fr=new JFrame("NotePad");
d=new FileDialog(fr,"Save",FileDialog.SAVE);
op=new FileDialog(fr,"Save",FileDialog.LOAD);
a=new JTextArea();

File=new JMenu("File");
Edit=new JMenu("Edit");
Format=new JMenu("Format");
View=new JMenu("View");
Help=new JMenu("Help");

New=new JMenuItem("New");
Exit=new JMenuItem("Exit");
Open=new JMenuItem("Open");
Save=new JMenuItem("Save");
Print=new JMenuItem("Print");
Cut=new JMenuItem("Cut");
Copy=new JMenuItem("Copy");
Paste=new JMenuItem("Paste");
Delete=new JMenuItem("Delete");

mb=new JMenuBar();

File.add(New);
File.add(Open);
File.add(Save);
File.add(Print);
File.add(Exit);

Edit.add(Cut);
Edit.add(Copy);
Edit.add(Paste);
Edit.add(Delete);

mb.add(File);
mb.add(Edit);
mb.add(Format);
mb.add(View);
mb.add(Help);

fr.setJMenuBar(mb);
Cut.setEnabled(false);
Copy.setEnabled(false);
Paste.setEnabled(false);
Save.setEnabled(false);
Delete.setEnabled(false);
Print.setEnabled(false);

New.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

fr.add(a);
fr.setTitle("Untitled-NotePad");
fr.setVisible(true);
Save.setEnabled(true);
Cut.setEnabled(true);
Copy.setEnabled(true);
Paste.setEnabled(true);
Delete.setEnabled(true);
Print.setEnabled(true);
}

});

Exit.addActionListener(new ActionListener() {


public void actionPerformed(ActionEvent arg0) {

fr.dispose();

}

});

Cut.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

try {
a.print();
} catch (PrinterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

});


Cut.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

a.cut();
}

});
Copy.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
a.copy();
}

});
Paste.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

a.paste();
}

});
Delete.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
a.replaceSelection("");
}

});
Save.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
String data=a.getText();
d.setVisible(true);
File f =new File(d.getDirectory(),d.getFile());
FileOutputStream r=null;
try {

r=new FileOutputStream(f,true);
char a[]=data.toCharArray();
int i=0;
while(i<a.length){
r.write((int)a[i]);
i++;
}
r.close();
                                       fr.setTitle(d.getFile()+" Notepad");
} catch (Exception e) {

e.printStackTrace();
}
}

});
Open.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {
op.setVisible(true);
File f =new File(op.getDirectory(),op.getFile());
FileInputStream in=null;
try {
in=new FileInputStream(f);
int ch=0;
StringBuffer line=new StringBuffer();
while((ch=in.read())!=-1) {
line.append((char)ch+"");
}
a.setText(line.toString());
fr.add(a);
fr.setTitle(op.getFile()+" Notepad");
fr.setVisible(true);
in.close();
}catch(Exception e ){

}
}

});


fr.pack();
fr.setSize(300,300);
fr.setVisible(true);
}
}
public class Notepad {

public static void main(String[] args) {
new notep();
}

}
Output:

CountDown Timer

Code:


class Timer implements Runnable{
Thread t;

int n;

public Timer(int x) {
t=new Thread(this);
n=x;
}


public void run() {
for(int i=n;i>0;i--) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println("Error: "+e);
}
System.out.println(i);
}

}

}
public class CountDown {


public static void main(String[] args) {
System.out.println("--Main Started--");

Timer t=new Timer(10);
t.t.start();
try {
t.t.join();
}catch(Exception e) {
System.out.println(e);
}


System.out.println("Happy New Year\n--Main Finished--");
}

}

Output: