Last Week we had a farewell in our college...
it was fantastic
Wednesday, November 19, 2008
Tuesday, October 14, 2008
Flames Program
Want a code For this Program?
Mail to the following Id .. u will get soon...
sendhamca@gmail.com
Mail to the following Id .. u will get soon...
sendhamca@gmail.com
Table in java
// senthil code for JTAble
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
public class Tabel extends JFrame
{
DefaultTableModel model1;
Object o2[];
JTable jTable1 ;JPanel panel;
public Tabel()
{
final JFrame frame=new JFrame("Student Records");
panel=new JPanel();
setContentPane(panel);
setTitle("STUDENTS Detail");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
setLayout(null);
jTable1 = new javax.swing.JTable();;
model1=new DefaultTableModel( new Object [][] { {"SID", "NAME", "GENDER"},
{null, null, null}},new String [] { null, null, null } );
jTable1=new JTable(model1);
jTable1.setBounds(330,60,700,360);;
add(jTable1); jTable1.setBounds(130,60,700,160);
o2=new Object[]{"110605069","senthil","Male"};
model1.addRow(o2);
}
public boolean handleEvent(Event e)
{
if(e.id==Event.WINDOW_DESTROY)
System.exit(0);
return(super.handleEvent(e));
}
public static void main(String d[])
{
new Tabel();
}
}
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
public class Tabel extends JFrame
{
DefaultTableModel model1;
Object o2[];
JTable jTable1 ;JPanel panel;
public Tabel()
{
final JFrame frame=new JFrame("Student Records");
panel=new JPanel();
setContentPane(panel);
setTitle("STUDENTS Detail");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
setLayout(null);
jTable1 = new javax.swing.JTable();;
model1=new DefaultTableModel( new Object [][] { {"SID", "NAME", "GENDER"},
{null, null, null}},new String [] { null, null, null } );
jTable1=new JTable(model1);
jTable1.setBounds(330,60,700,360);;
add(jTable1); jTable1.setBounds(130,60,700,160);
o2=new Object[]{"110605069","senthil","Male"};
model1.addRow(o2);
}
public boolean handleEvent(Event e)
{
if(e.id==Event.WINDOW_DESTROY)
System.exit(0);
return(super.handleEvent(e));
}
public static void main(String d[])
{
new Tabel();
}
}
Mini Browser in java
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.html.*;
// The Mini Web Browser.
public class MiniBrowser extends JFrame
implements HyperlinkListener
{
// These are the buttons for iterating through the page list.
private JButton backButton, forwardButton;
// Page location text field.
private JTextField locationTextField;
// Editor pane for displaying pages.
private JEditorPane displayEditorPane;
// Browser's list of pages that have been visited.
private ArrayList pageList = new ArrayList();
// Constructor for Mini Web Browser.
public MiniBrowser()
{
// Set application title.
super("Mini Browser");
// Set window size.
setSize(640, 480);
// Handle closing events.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
actionExit();
}
});
// Set up file menu.
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
JMenuItem fileExitMenuItem = new JMenuItem("Exit",
KeyEvent.VK_X);
fileExitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionExit();
}
});
fileMenu.add(fileExitMenuItem);
menuBar.add(fileMenu);
setJMenuBar(menuBar);
// Set up button panel.
JPanel buttonPanel = new JPanel();
backButton = new JButton("< Back");
backButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionBack();
}
});
backButton.setEnabled(false);
buttonPanel.add(backButton);
forwardButton = new JButton("Forward >");
forwardButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionForward();
}
});
forwardButton.setEnabled(false);
buttonPanel.add(forwardButton);
locationTextField = new JTextField(35);
locationTextField.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
actionGo();
}
}
});
buttonPanel.add(locationTextField);
JButton goButton = new JButton("GO");
goButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionGo();
}
});
buttonPanel.add(goButton);
// Set up page display.
displayEditorPane = new JEditorPane();
displayEditorPane.setContentType("text/html");
displayEditorPane.setEditable(false);
displayEditorPane.addHyperlinkListener(this);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(buttonPanel, BorderLayout.NORTH);
getContentPane().add(new JScrollPane(displayEditorPane),
BorderLayout.CENTER);
}
// Exit this program.
private void actionExit() {
System.exit(0);
}
// Go back to the page viewed before the current page.
private void actionBack() {
URL currentUrl = displayEditorPane.getPage();
int pageIndex = pageList.indexOf(currentUrl.toString());
try {
showPage(
new URL((String) pageList.get(pageIndex - 1)), false);
}
catch (Exception e) {}
}
// Go forward to the page viewed after the current page.
private void actionForward() {
URL currentUrl = displayEditorPane.getPage();
int pageIndex = pageList.indexOf(currentUrl.toString());
try {
showPage(
new URL((String) pageList.get(pageIndex + 1)), false);
}
catch (Exception e) {}
}
// Load and show the page specified in the location text field.
private void actionGo() {
URL verifiedUrl = verifyUrl(locationTextField.getText());
if (verifiedUrl != null) {
showPage(verifiedUrl, true);
} else {
showError("Invalid URL");
}
}
// Show dialog box with error message.
private void showError(String errorMessage) {
JOptionPane.showMessageDialog(this, errorMessage,
"Error", JOptionPane.ERROR_MESSAGE);
}
// Verify URL format.
private URL verifyUrl(String url) {
// Only allow HTTP URLs.
if (!url.toLowerCase().startsWith("http://"))
return null;
// Verify format of URL.
URL verifiedUrl = null;
try {
verifiedUrl = new URL(url);
} catch (Exception e) {
return null;
}
return verifiedUrl;
}
/* Show the specified page and add it to
the page list if specified. */
private void showPage(URL pageUrl, boolean addToList)
{
// Show hour glass cursor while crawling is under way.
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
// Get URL of page currently being displayed.
URL currentUrl = displayEditorPane.getPage();
// Load and display specified page.
displayEditorPane.setPage(pageUrl);
// Get URL of new page being displayed.
URL newUrl = displayEditorPane.getPage();
// Add page to list if specified.
if (addToList) {
int listSize = pageList.size();
if (listSize > 0) {
int pageIndex =
pageList.indexOf(currentUrl.toString());
if (pageIndex < listSize - 1) {
for (int i = listSize - 1; i > pageIndex; i--) {
pageList.remove(i);
}
}
}
pageList.add(newUrl.toString());
}
// Update location text field with URL of current page.
locationTextField.setText(newUrl.toString());
// Update buttons based on the page being displayed.
updateButtons();
}
catch (Exception e)
{
// Show error messsage.
showError("Unable to load page");
}
finally
{
// Return to default cursor.
setCursor(Cursor.getDefaultCursor());
}
}
/* Update back and forward buttons based on
the page being displayed. */
private void updateButtons() {
if (pageList.size() < 2) {
backButton.setEnabled(false);
forwardButton.setEnabled(false);
} else {
URL currentUrl = displayEditorPane.getPage();
int pageIndex = pageList.indexOf(currentUrl.toString());
backButton.setEnabled(pageIndex > 0);
forwardButton.setEnabled(
pageIndex < (pageList.size() - 1));
}
}
// Handle hyperlink's being clicked.
public void hyperlinkUpdate(HyperlinkEvent event) {
HyperlinkEvent.EventType eventType = event.getEventType();
if (eventType == HyperlinkEvent.EventType.ACTIVATED) {
if (event instanceof HTMLFrameHyperlinkEvent) {
HTMLFrameHyperlinkEvent linkEvent =
(HTMLFrameHyperlinkEvent) event;
HTMLDocument document =
(HTMLDocument) displayEditorPane.getDocument();
document.processHTMLFrameHyperlinkEvent(linkEvent);
} else {
showPage(event.getURL(), true);
}
}
}
// Run the Mini Browser.
public static void main(String[] args) {
MiniBrowser browser = new MiniBrowser();
browser.show();
}
}
import java.awt.event.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.html.*;
// The Mini Web Browser.
public class MiniBrowser extends JFrame
implements HyperlinkListener
{
// These are the buttons for iterating through the page list.
private JButton backButton, forwardButton;
// Page location text field.
private JTextField locationTextField;
// Editor pane for displaying pages.
private JEditorPane displayEditorPane;
// Browser's list of pages that have been visited.
private ArrayList pageList = new ArrayList();
// Constructor for Mini Web Browser.
public MiniBrowser()
{
// Set application title.
super("Mini Browser");
// Set window size.
setSize(640, 480);
// Handle closing events.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
actionExit();
}
});
// Set up file menu.
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
JMenuItem fileExitMenuItem = new JMenuItem("Exit",
KeyEvent.VK_X);
fileExitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionExit();
}
});
fileMenu.add(fileExitMenuItem);
menuBar.add(fileMenu);
setJMenuBar(menuBar);
// Set up button panel.
JPanel buttonPanel = new JPanel();
backButton = new JButton("< Back");
backButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionBack();
}
});
backButton.setEnabled(false);
buttonPanel.add(backButton);
forwardButton = new JButton("Forward >");
forwardButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionForward();
}
});
forwardButton.setEnabled(false);
buttonPanel.add(forwardButton);
locationTextField = new JTextField(35);
locationTextField.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
actionGo();
}
}
});
buttonPanel.add(locationTextField);
JButton goButton = new JButton("GO");
goButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionGo();
}
});
buttonPanel.add(goButton);
// Set up page display.
displayEditorPane = new JEditorPane();
displayEditorPane.setContentType("text/html");
displayEditorPane.setEditable(false);
displayEditorPane.addHyperlinkListener(this);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(buttonPanel, BorderLayout.NORTH);
getContentPane().add(new JScrollPane(displayEditorPane),
BorderLayout.CENTER);
}
// Exit this program.
private void actionExit() {
System.exit(0);
}
// Go back to the page viewed before the current page.
private void actionBack() {
URL currentUrl = displayEditorPane.getPage();
int pageIndex = pageList.indexOf(currentUrl.toString());
try {
showPage(
new URL((String) pageList.get(pageIndex - 1)), false);
}
catch (Exception e) {}
}
// Go forward to the page viewed after the current page.
private void actionForward() {
URL currentUrl = displayEditorPane.getPage();
int pageIndex = pageList.indexOf(currentUrl.toString());
try {
showPage(
new URL((String) pageList.get(pageIndex + 1)), false);
}
catch (Exception e) {}
}
// Load and show the page specified in the location text field.
private void actionGo() {
URL verifiedUrl = verifyUrl(locationTextField.getText());
if (verifiedUrl != null) {
showPage(verifiedUrl, true);
} else {
showError("Invalid URL");
}
}
// Show dialog box with error message.
private void showError(String errorMessage) {
JOptionPane.showMessageDialog(this, errorMessage,
"Error", JOptionPane.ERROR_MESSAGE);
}
// Verify URL format.
private URL verifyUrl(String url) {
// Only allow HTTP URLs.
if (!url.toLowerCase().startsWith("http://"))
return null;
// Verify format of URL.
URL verifiedUrl = null;
try {
verifiedUrl = new URL(url);
} catch (Exception e) {
return null;
}
return verifiedUrl;
}
/* Show the specified page and add it to
the page list if specified. */
private void showPage(URL pageUrl, boolean addToList)
{
// Show hour glass cursor while crawling is under way.
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
// Get URL of page currently being displayed.
URL currentUrl = displayEditorPane.getPage();
// Load and display specified page.
displayEditorPane.setPage(pageUrl);
// Get URL of new page being displayed.
URL newUrl = displayEditorPane.getPage();
// Add page to list if specified.
if (addToList) {
int listSize = pageList.size();
if (listSize > 0) {
int pageIndex =
pageList.indexOf(currentUrl.toString());
if (pageIndex < listSize - 1) {
for (int i = listSize - 1; i > pageIndex; i--) {
pageList.remove(i);
}
}
}
pageList.add(newUrl.toString());
}
// Update location text field with URL of current page.
locationTextField.setText(newUrl.toString());
// Update buttons based on the page being displayed.
updateButtons();
}
catch (Exception e)
{
// Show error messsage.
showError("Unable to load page");
}
finally
{
// Return to default cursor.
setCursor(Cursor.getDefaultCursor());
}
}
/* Update back and forward buttons based on
the page being displayed. */
private void updateButtons() {
if (pageList.size() < 2) {
backButton.setEnabled(false);
forwardButton.setEnabled(false);
} else {
URL currentUrl = displayEditorPane.getPage();
int pageIndex = pageList.indexOf(currentUrl.toString());
backButton.setEnabled(pageIndex > 0);
forwardButton.setEnabled(
pageIndex < (pageList.size() - 1));
}
}
// Handle hyperlink's being clicked.
public void hyperlinkUpdate(HyperlinkEvent event) {
HyperlinkEvent.EventType eventType = event.getEventType();
if (eventType == HyperlinkEvent.EventType.ACTIVATED) {
if (event instanceof HTMLFrameHyperlinkEvent) {
HTMLFrameHyperlinkEvent linkEvent =
(HTMLFrameHyperlinkEvent) event;
HTMLDocument document =
(HTMLDocument) displayEditorPane.getDocument();
document.processHTMLFrameHyperlinkEvent(linkEvent);
} else {
showPage(event.getURL(), true);
}
}
}
// Run the Mini Browser.
public static void main(String[] args) {
MiniBrowser browser = new MiniBrowser();
browser.show();
}
}
Search engine in java
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
class window extends JFrame implements ActionListener
{
String drives[] = new String[6];
static JCheckBox cb[];
static JComboBox jcb;
JPanel p[]=new JPanel[8];
java.awt.List t[] = new java.awt.List[7];
TextField tf;
//creathrd obj[];
JButton b1,b2;
static JRadioButton rb1,rb2,rb3,rb4,rb5;
Label ltot=new Label();
window(String title)
{
super(title);
validDri vd = new validDri();
try
{
drives=vd.valdrive();
}
catch(Exception e)
{}
setLayout(new GridLayout(2,4));
for(int i=0;i<8;i++)
{
p[i]=new JPanel();
}
p[0].setLayout(new GridLayout(8,1));
p[4].setLayout(new GridLayout(9,1));
for(int i=1;i<8;i++)
{
if(i!=4)
p[i].setLayout(new GridLayout(1,1)); ////////////////// DOUBT
}
for(int i=0;i<6;i++)
{
t[i]=new java.awt.List();//////////////////// DOUBT
}
for(int i=0;i {
t[i].add("DRIVE "+drives[i]);
t[i].addActionListener(this);
}
JLabel L1=new JLabel("Enter the KeyWord to be Searched");
JLabel a = new JLabel("");
JLabel c = new JLabel("");
JLabel d = new JLabel("");
JLabel b = new JLabel("");
rb3 = new JRadioButton("Contents Search");
rb4 = new JRadioButton("FileName Search",true);
rb5 = new JRadioButton("Both");
rb3.addActionListener(this);
rb4.addActionListener(this);
rb5.addActionListener(this);
ButtonGroup bg1 = new ButtonGroup();
bg1.add(rb3);
bg1.add(rb4);
bg1.add(rb5);
tf = new TextField(50);
rb1 = new JRadioButton("DEFAULT");
jcb = new JComboBox();
jcb.addItem("ALL");
for(int i=0;i {
jcb.addItem(drives[i]);
}
//BUTTONS FOR STARTING AND STOPPING THE SEARCH
b1 = new JButton("SEARCH");
b2 = new JButton("STOP");
//b1.setBounds(40,440,40,450);
b1.addActionListener(this);
b2.addActionListener(this);
rb2 = new JRadioButton("OTHERS");
cb = new JCheckBox[drives.length];
for(int i=0;i {
cb[i]=new JCheckBox(drives[i]);
cb[i].setEnabled(false);
}
rb1.addActionListener(this);
rb2.addActionListener(this);
ButtonGroup bg = new ButtonGroup();
bg.add(rb1);
bg.add(rb2);
p[0].add(L1);
p[0].add(a);
p[0].add(tf);
p[0].add(rb3);
p[0].add(rb4);
p[0].add(rb5);
p[0].add(ltot);
p[0].add(jcb);
p[1].add(t[0]);
p[2].add(t[1]);
p[3].add(t[2]);
p[4].add(rb1);
p[4].add(jcb);
p[4].add(rb2);
for(int i=0;i p[4].add(cb[i]);
p[4].add(b1);
//p[4].add(b2);
p[5].add(t[3]);
p[6].add(t[4]);
p[7].add(t[5]);
GridBagConstraints g = new GridBagConstraints();
g.gridx=0;
g.gridy=0;
add(p[0]);
g.gridx++;
add(p[1]);
g.gridx++;
add(p[2]);
g.gridx++;
add(p[3]);
g.gridy++;
g.gridx=0;
add(p[4]);
g.gridx++;
add(p[5]);
g.gridx++;
add(p[6]);
g.gridx++;
add(p[7]);
addWindowListener(new windowadapter());
}
public void actionPerformed(ActionEvent ae)
{
String tem=ae.getActionCommand();
int ind=0;
for(int j=0;j if(tem.contains(drives[j]))
{
ind=j;
break;
}
String s1=this.t[ind].getSelectedItem();
if(ae.getActionCommand().equals("DEFAULT"))
{
for(int i=0;i this.cb[i].setEnabled(false);
this.jcb.setEnabled(true);
}
else if(ae.getActionCommand().equals("OTHERS"))
{
this.jcb.setEnabled(false);
for(int i=0;i this.cb[i].setEnabled(true);
}
else if(ae.getActionCommand().equals(s1))
{
}
else if(ae.getActionCommand().equals("SEARCH"))
{
/*String fname;
String drives1[] = new String[drives.length];
ltot.setText("");
for(int i=0;i drives1[i]=drives[i];
fname=this.tf.getText();
fname=convert(fname);
System.out.println("Converted String : "+fname);
System.out.println();
System.out.println();
for(int i=0;i<6;i++)
t[i].clear();
drives1=limit(drives1);
for(int i=0;i if(drives1[i].equals("null")==false)
t[i].add("DRIVE "+drives1[i]);
obj=new creathrd[drives1.length];
for(int i=0;i if(drives1[i].equals("null")==false)
obj[i]=new creathrd(drives1[i],fname,this,drives1);
infacethrd ob=new infacethrd(fname,this);
for(int i=0;i {
try{
obj[i].t.join();
}
catch(Exception e){}
}
try{
ob.t.join();
}catch(Exception e){}
System.out.println();
int tot=0;
for(int i=0;i if(drives1[i].equals("null")==false)
tot+=obj[i].fc;
System.out.println("Total Number of Files Found is :"+tot);
ltot.setText("Total Number of Files Found is :"+tot);
//p[0].add(ltot);
System.out.println("Finished");*/
}
}
class windowadapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(1);
}
}
class validDri
{
String[] valdrive() throws IOException
{
String drives[]={"A:\\","B:\\","C:\\","D:\\","E:\\","F:\\"};
String drlist[]=new String[6];
String temp[];
int idx=0,inc=0;
for(int i=0;i {
File f = new File(drives[i]);
if(f!=null)
{
temp=f.list();
if(temp!=null)
{
drlist[idx]=drives[i];
idx++;
}
}
}
for(int j=0;j {
if(drlist[j]!=null)
{
inc++;
}
}
String vallist[]=new String[inc];
for(int k=0;k {
if(drlist[k]!=null)
vallist[k]=drlist[k];
}
return vallist;
}
}
}
class search
{
public static void main(String args[]) throws IOException
{
boolean flag;
int tot;
String fname;
//validDri vd1 = new validDri();
String valdri[] = new String[26];
//valdri=vd1.valdrive();
//creathrd obj[]=new creathrd[valdri.length];
window w = new window("Search Engine");
//new infacethrd("Interface",w);
w.setSize(750,450);
w.setBounds(0,0,800,572);
w.setVisible(true);
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
class window extends JFrame implements ActionListener
{
String drives[] = new String[6];
static JCheckBox cb[];
static JComboBox jcb;
JPanel p[]=new JPanel[8];
java.awt.List t[] = new java.awt.List[7];
TextField tf;
//creathrd obj[];
JButton b1,b2;
static JRadioButton rb1,rb2,rb3,rb4,rb5;
Label ltot=new Label();
window(String title)
{
super(title);
validDri vd = new validDri();
try
{
drives=vd.valdrive();
}
catch(Exception e)
{}
setLayout(new GridLayout(2,4));
for(int i=0;i<8;i++)
{
p[i]=new JPanel();
}
p[0].setLayout(new GridLayout(8,1));
p[4].setLayout(new GridLayout(9,1));
for(int i=1;i<8;i++)
{
if(i!=4)
p[i].setLayout(new GridLayout(1,1)); ////////////////// DOUBT
}
for(int i=0;i<6;i++)
{
t[i]=new java.awt.List();//////////////////// DOUBT
}
for(int i=0;i
t[i].add("DRIVE "+drives[i]);
t[i].addActionListener(this);
}
JLabel L1=new JLabel("Enter the KeyWord to be Searched");
JLabel a = new JLabel("");
JLabel c = new JLabel("");
JLabel d = new JLabel("");
JLabel b = new JLabel("");
rb3 = new JRadioButton("Contents Search");
rb4 = new JRadioButton("FileName Search",true);
rb5 = new JRadioButton("Both");
rb3.addActionListener(this);
rb4.addActionListener(this);
rb5.addActionListener(this);
ButtonGroup bg1 = new ButtonGroup();
bg1.add(rb3);
bg1.add(rb4);
bg1.add(rb5);
tf = new TextField(50);
rb1 = new JRadioButton("DEFAULT");
jcb = new JComboBox();
jcb.addItem("ALL");
for(int i=0;i
jcb.addItem(drives[i]);
}
//BUTTONS FOR STARTING AND STOPPING THE SEARCH
b1 = new JButton("SEARCH");
b2 = new JButton("STOP");
//b1.setBounds(40,440,40,450);
b1.addActionListener(this);
b2.addActionListener(this);
rb2 = new JRadioButton("OTHERS");
cb = new JCheckBox[drives.length];
for(int i=0;i
cb[i]=new JCheckBox(drives[i]);
cb[i].setEnabled(false);
}
rb1.addActionListener(this);
rb2.addActionListener(this);
ButtonGroup bg = new ButtonGroup();
bg.add(rb1);
bg.add(rb2);
p[0].add(L1);
p[0].add(a);
p[0].add(tf);
p[0].add(rb3);
p[0].add(rb4);
p[0].add(rb5);
p[0].add(ltot);
p[0].add(jcb);
p[1].add(t[0]);
p[2].add(t[1]);
p[3].add(t[2]);
p[4].add(rb1);
p[4].add(jcb);
p[4].add(rb2);
for(int i=0;i
p[4].add(b1);
//p[4].add(b2);
p[5].add(t[3]);
p[6].add(t[4]);
p[7].add(t[5]);
GridBagConstraints g = new GridBagConstraints();
g.gridx=0;
g.gridy=0;
add(p[0]);
g.gridx++;
add(p[1]);
g.gridx++;
add(p[2]);
g.gridx++;
add(p[3]);
g.gridy++;
g.gridx=0;
add(p[4]);
g.gridx++;
add(p[5]);
g.gridx++;
add(p[6]);
g.gridx++;
add(p[7]);
addWindowListener(new windowadapter());
}
public void actionPerformed(ActionEvent ae)
{
String tem=ae.getActionCommand();
int ind=0;
for(int j=0;j
{
ind=j;
break;
}
String s1=this.t[ind].getSelectedItem();
if(ae.getActionCommand().equals("DEFAULT"))
{
for(int i=0;i
this.jcb.setEnabled(true);
}
else if(ae.getActionCommand().equals("OTHERS"))
{
this.jcb.setEnabled(false);
for(int i=0;i
}
else if(ae.getActionCommand().equals(s1))
{
}
else if(ae.getActionCommand().equals("SEARCH"))
{
/*String fname;
String drives1[] = new String[drives.length];
ltot.setText("");
for(int i=0;i
fname=this.tf.getText();
fname=convert(fname);
System.out.println("Converted String : "+fname);
System.out.println();
System.out.println();
for(int i=0;i<6;i++)
t[i].clear();
drives1=limit(drives1);
for(int i=0;i
t[i].add("DRIVE "+drives1[i]);
obj=new creathrd[drives1.length];
for(int i=0;i
obj[i]=new creathrd(drives1[i],fname,this,drives1);
infacethrd ob=new infacethrd(fname,this);
for(int i=0;i
try{
obj[i].t.join();
}
catch(Exception e){}
}
try{
ob.t.join();
}catch(Exception e){}
System.out.println();
int tot=0;
for(int i=0;i
tot+=obj[i].fc;
System.out.println("Total Number of Files Found is :"+tot);
ltot.setText("Total Number of Files Found is :"+tot);
//p[0].add(ltot);
System.out.println("Finished");*/
}
}
class windowadapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(1);
}
}
class validDri
{
String[] valdrive() throws IOException
{
String drives[]={"A:\\","B:\\","C:\\","D:\\","E:\\","F:\\"};
String drlist[]=new String[6];
String temp[];
int idx=0,inc=0;
for(int i=0;i
File f = new File(drives[i]);
if(f!=null)
{
temp=f.list();
if(temp!=null)
{
drlist[idx]=drives[i];
idx++;
}
}
}
for(int j=0;j
if(drlist[j]!=null)
{
inc++;
}
}
String vallist[]=new String[inc];
for(int k=0;k
if(drlist[k]!=null)
vallist[k]=drlist[k];
}
return vallist;
}
}
}
class search
{
public static void main(String args[]) throws IOException
{
boolean flag;
int tot;
String fname;
//validDri vd1 = new validDri();
String valdri[] = new String[26];
//valdri=vd1.valdrive();
//creathrd obj[]=new creathrd[valdri.length];
window w = new window("Search Engine");
//new infacethrd("Interface",w);
w.setSize(750,450);
w.setBounds(0,0,800,572);
w.setVisible(true);
}
}
Calendar in C++
//senthil code for calendar in c++
#include
#include
void main()
{
int odd=0,yr,mth,dt;
int jan=31,feb=0,mar=31,apr=30,may=31,june=30,july=31,aug=30,sep=31,oct=30;
int nov=31,dec=30,rem; int s[5][7];
clrscr();
cout<<"\nEnter The Year \n";
cin>>yr;
cout<<"\n Entr The Month \n";
cin>>mth;
cout<<"\n Enter The Date \n";
cin>>dt;
if(!(yr<0&&mth>12))
{ if(dt>0&&dt<31) {
if(yr%4==0)
feb=29;
else
feb=28;
yr=yr-1;
if(yr>400)
rem=yr%400;
else
rem=yr;
if(rem>300&&rem<400)
{
rem=rem%300;
odd=odd+1;
}
if(rem>200&&rem<300)
{
rem=rem%200;
odd=odd+3;
}
if(rem>100&&rem<200)
{
rem=rem%100;
odd=odd+5;
}
//cout<<"now odd is"< int leap=rem/4;
// cout<<"the leap is "< int ordyr=rem-leap;
// cout<<"the ordi yre is"< int todd=(ordyr*1)+(leap*2);
todd=todd%7;
odd=todd+odd;
//cout<<"the yr odd toal is"< if(odd>=7)
{
odd=odd%7;
}
else { }
//cout<<"\n the odd"< int modd=0;
switch(mth)
{
case 1:
modd=dt; break;
case 2:
modd=jan+dt; break;
case 3:
modd=jan+feb+dt; break;
case 4:
modd=jan+feb+mar+dt; break;
case 5:
modd=jan+feb+mar+apr+dt; break;
case 6:
modd=jan+feb+mar+apr+may+dt; break;
case 7:
modd=jan+feb+mar+apr+may+june+dt; break;
case 8:
modd=jan+feb+mar+apr+may+june+july+dt; break;
case 9:
modd=jan+feb+mar+apr+may+june+july+aug+dt; break;
case 10:
modd=jan+feb+mar+apr+may+june+july+aug+sep+dt; break;
case 11:
modd=jan+feb+mar+apr+may+june+july+aug+sep+oct+dt; break;
case 12:
modd=jan+feb+mar+apr+may+june+july+aug+sep+oct+nov+dt; break;
}
modd=modd%7;
// cout<<"the month odd is after devided by 7 "< odd=odd+modd;
if(odd>=7)
odd=odd%7;
//cout<<"\n the odd"<
switch(odd)
{
case 0:
cout<<" THE DAY IS SUNDAY \n";
break;
case 1:
cout<<" THE DAY IS MONDAY \n";
break;
case 2:
cout<<" THE DAY IS TUESDAY \n";
break;
case 3:
cout<<" THE DAY IS WEDNESDAY \n";
break;
case 4:
cout<<" THE DAY IS THURSDAY \n";
break;
case 5:
cout<<" THE DAY IS FRIDAY \n";
break;
case 6:
cout<<" THE DAY IS SATURDAY\n";
break;
default:cout<<"wrong";
}
cout<<" s "<<"M "<<"T "<<"W "<<"T "<<"F "<<"S \n";
int y=0;
for(int i=0;i<5;i++)
{
for(int j=0;j<7;j++)
{ y++;
s[i][j+odd]=y;
cout<}
cout< }
}
else
{
cout<<"\ncheck the year and month and date whether valid or not";
}
}// if ends here
getch();
}
#include
#include
void main()
{
int odd=0,yr,mth,dt;
int jan=31,feb=0,mar=31,apr=30,may=31,june=30,july=31,aug=30,sep=31,oct=30;
int nov=31,dec=30,rem; int s[5][7];
clrscr();
cout<<"\nEnter The Year \n";
cin>>yr;
cout<<"\n Entr The Month \n";
cin>>mth;
cout<<"\n Enter The Date \n";
cin>>dt;
if(!(yr<0&&mth>12))
{ if(dt>0&&dt<31) {
if(yr%4==0)
feb=29;
else
feb=28;
yr=yr-1;
if(yr>400)
rem=yr%400;
else
rem=yr;
if(rem>300&&rem<400)
{
rem=rem%300;
odd=odd+1;
}
if(rem>200&&rem<300)
{
rem=rem%200;
odd=odd+3;
}
if(rem>100&&rem<200)
{
rem=rem%100;
odd=odd+5;
}
//cout<<"now odd is"<
// cout<<"the leap is "<
// cout<<"the ordi yre is"<
todd=todd%7;
odd=todd+odd;
//cout<<"the yr odd toal is"<
{
odd=odd%7;
}
else { }
//cout<<"\n the odd"<
switch(mth)
{
case 1:
modd=dt; break;
case 2:
modd=jan+dt; break;
case 3:
modd=jan+feb+dt; break;
case 4:
modd=jan+feb+mar+dt; break;
case 5:
modd=jan+feb+mar+apr+dt; break;
case 6:
modd=jan+feb+mar+apr+may+dt; break;
case 7:
modd=jan+feb+mar+apr+may+june+dt; break;
case 8:
modd=jan+feb+mar+apr+may+june+july+dt; break;
case 9:
modd=jan+feb+mar+apr+may+june+july+aug+dt; break;
case 10:
modd=jan+feb+mar+apr+may+june+july+aug+sep+dt; break;
case 11:
modd=jan+feb+mar+apr+may+june+july+aug+sep+oct+dt; break;
case 12:
modd=jan+feb+mar+apr+may+june+july+aug+sep+oct+nov+dt; break;
}
modd=modd%7;
// cout<<"the month odd is after devided by 7 "<
if(odd>=7)
odd=odd%7;
//cout<<"\n the odd"<
switch(odd)
{
case 0:
cout<<" THE DAY IS SUNDAY \n";
break;
case 1:
cout<<" THE DAY IS MONDAY \n";
break;
case 2:
cout<<" THE DAY IS TUESDAY \n";
break;
case 3:
cout<<" THE DAY IS WEDNESDAY \n";
break;
case 4:
cout<<" THE DAY IS THURSDAY \n";
break;
case 5:
cout<<" THE DAY IS FRIDAY \n";
break;
case 6:
cout<<" THE DAY IS SATURDAY\n";
break;
default:cout<<"wrong";
}
cout<<" s "<<"M "<<"T "<<"W "<<"T "<<"F "<<"S \n";
int y=0;
for(int i=0;i<5;i++)
{
for(int j=0;j<7;j++)
{ y++;
s[i][j+odd]=y;
cout<
cout<
}
else
{
cout<<"\ncheck the year and month and date whether valid or not";
}
}// if ends here
getch();
}
Calendar program in applet
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Calendar extends Applet implements ActionListener
{
Label l,l2;
TextField t1,t2;
Button b;
TextArea ta;
public void init()
{
//setLayout(new GridLayout(4,4));
l=new Label("Enter Year ");
t1=new TextField(20);
l2=new Label("Enter Month ");
t2=new TextField(20);
b=new Button("Click Here To Display Calendar");
ta=new TextArea(10,55);
add(l);
add(t1);
add(l2);
add(t2);
add(b);
add(ta);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
try
{
int y=Integer.parseInt(t1.getText());
int m=Integer.parseInt(t2.getText());
ta.setText("");
ta.append("\tSun\tMon\tTue\tWed\tThu\tFri\tSat\n");
calc(y,m);
}
catch(Exception e)
{
ta.append("\t\tWrong Input OR No Input\n\n\t\tPlease Enter Correct MOnth and Year");
}
}
public void calc(int year,int month)
{
int p400,pr,odd=0,leapyr,seek=8,ordyr,totday=0,oddaft;
int jan=31,feb=0,mar=31,apr=30,may=31,jun=30,jul=31,aug=31,sep=30,oct=31,nov=30;
p400=(year-1)%400;
if(p400>300)
{
pr=p400%300;
odd=odd+1;
}
else if(p400>200)
{
pr=p400%200;
odd=odd+3;
}
else if(p400>100)
{
pr=p400%100;
odd=odd+5;
}
else
{
pr=p400;
}
leapyr=pr/4;
ordyr=pr-leapyr;
odd=odd+(leapyr*2)+ordyr;
odd=odd%7;
if(year%4==0)
{
feb=29;
}
else
{
feb=28;
}
switch(month)
{
case 1:
totday=0;
break;
case 2:
totday=jan;
break;
case 3:
totday=jan+feb;
break;
case 4:
totday=jan+feb+mar;
break;
case 5:
totday=jan+feb+mar+apr;
break;
case 6:
totday=jan+feb+mar+apr+may;
break;
case 7:
totday=jan+feb+mar+apr+may+jun;
break;
case 8:
totday=jan+feb+mar+apr+may+jun+jul;
break;
case 9:
totday=jan+feb+mar+apr+may+jun+jul+aug;
break;
case 10:
totday=jan+feb+mar+apr+may+jun+jul+aug+sep;
break;
case 11:
totday=jan+feb+mar+apr+may+jun+jul+aug+sep+oct;
break;
case 12:
totday=jan+feb+mar+apr+may+jun+jul+aug+sep+oct+nov;
break;
}
oddaft=totday %7;
odd=(odd+oddaft)%7;
odd=odd+1;
for(int j=0;j {
ta.append("\t");
}
for(int i=1;i<32;i++)
{
if(i==(seek-odd) || i==(seek+7-odd) || i==(seek+7+7-odd) || i==(seek+7+14-odd) || i==(seek+7+21-odd))
{
ta.append("\n"+"\t"+i);
}
else
{
ta.append("\t"+i);
}
}
}
}
/**/
import java.awt.*;
import java.awt.event.*;
public class Calendar extends Applet implements ActionListener
{
Label l,l2;
TextField t1,t2;
Button b;
TextArea ta;
public void init()
{
//setLayout(new GridLayout(4,4));
l=new Label("Enter Year ");
t1=new TextField(20);
l2=new Label("Enter Month ");
t2=new TextField(20);
b=new Button("Click Here To Display Calendar");
ta=new TextArea(10,55);
add(l);
add(t1);
add(l2);
add(t2);
add(b);
add(ta);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
try
{
int y=Integer.parseInt(t1.getText());
int m=Integer.parseInt(t2.getText());
ta.setText("");
ta.append("\tSun\tMon\tTue\tWed\tThu\tFri\tSat\n");
calc(y,m);
}
catch(Exception e)
{
ta.append("\t\tWrong Input OR No Input\n\n\t\tPlease Enter Correct MOnth and Year");
}
}
public void calc(int year,int month)
{
int p400,pr,odd=0,leapyr,seek=8,ordyr,totday=0,oddaft;
int jan=31,feb=0,mar=31,apr=30,may=31,jun=30,jul=31,aug=31,sep=30,oct=31,nov=30;
p400=(year-1)%400;
if(p400>300)
{
pr=p400%300;
odd=odd+1;
}
else if(p400>200)
{
pr=p400%200;
odd=odd+3;
}
else if(p400>100)
{
pr=p400%100;
odd=odd+5;
}
else
{
pr=p400;
}
leapyr=pr/4;
ordyr=pr-leapyr;
odd=odd+(leapyr*2)+ordyr;
odd=odd%7;
if(year%4==0)
{
feb=29;
}
else
{
feb=28;
}
switch(month)
{
case 1:
totday=0;
break;
case 2:
totday=jan;
break;
case 3:
totday=jan+feb;
break;
case 4:
totday=jan+feb+mar;
break;
case 5:
totday=jan+feb+mar+apr;
break;
case 6:
totday=jan+feb+mar+apr+may;
break;
case 7:
totday=jan+feb+mar+apr+may+jun;
break;
case 8:
totday=jan+feb+mar+apr+may+jun+jul;
break;
case 9:
totday=jan+feb+mar+apr+may+jun+jul+aug;
break;
case 10:
totday=jan+feb+mar+apr+may+jun+jul+aug+sep;
break;
case 11:
totday=jan+feb+mar+apr+may+jun+jul+aug+sep+oct;
break;
case 12:
totday=jan+feb+mar+apr+may+jun+jul+aug+sep+oct+nov;
break;
}
oddaft=totday %7;
odd=(odd+oddaft)%7;
odd=odd+1;
for(int j=0;j
ta.append("\t");
}
for(int i=1;i<32;i++)
{
if(i==(seek-odd) || i==(seek+7-odd) || i==(seek+7+7-odd) || i==(seek+7+14-odd) || i==(seek+7+21-odd))
{
ta.append("\n"+"\t"+i);
}
else
{
ta.append("\t"+i);
}
}
}
}
/**/
Subscribe to:
Posts (Atom)

