Java program - to open internet explorer in java

10 views
Skip to first unread message

Justin

unread,
Jul 22, 2006, 6:45:38 AM7/22/06
to Exam Bells !!! - Group for Sem exam preparation
/*The following program contains a JTextField , and when you type the
address of a website and click open ,
that website open up in internet explorer*/

//OpeningIETest.java
//Author : Justin , 2006 ,please distibute this but do keep the source
open

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class OpeningIE extends JFrame
{
Process p =null;
ImageIcon IEIcon ;
Icon IEIcon2;
JTextField fieldInput;
JButton buttonOpen;
JLabel labelAddress;
Cursor myCursor;
OpeningIE ()
{
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.BLACK);

labelAddress = new JLabel ("Address:");
labelAddress .setForeground(Color.RED);
myCursor =new Cursor( HAND_CURSOR );

fieldInput = new JTextField (15);
fieldInput .setForeground(Color.PINK);
fieldInput .setFont(new Font("SansSerif" , Font.BOLD, 17));
fieldInput .setToolTipText("Enter the address of the site here");
fieldInput.setBackground(Color.BLACK);

IEIcon = new ImageIcon("ieIcon.jpg");
IEIcon2 = new ImageIcon("ieIcon2.jpg");

buttonOpen = new JButton("Click to open internet explorer",IEIcon );
buttonOpen.setRolloverIcon(IEIcon2 );

buttonOpen.setCursor(myCursor );
buttonOpen.setBackground(Color.ORANGE);
c.add(labelAddress );
c.add(fieldInput );
c.add(buttonOpen );

OpeningIEHandler o1 = new OpeningIEHandler ();
buttonOpen.addActionListener(o1);
fieldInput.addActionListener(o1);
} //end of constructor

private class OpeningIEHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String address = fieldInput.getText();

Runtime r = Runtime.getRuntime();
try
{
p =r.exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE
"+address);
}
catch(Exception ex)
{
}
} //end of actionPerformed
} // end of inner class
} //end of outer class

class OpeningIETest
{
public static void main(String args[])
{
OpeningIE o1 = new OpeningIE ();
o1.setSize(300,400);
o1.setVisible(true);
o1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

//********************************************************************

Justin

unread,
Jul 22, 2006, 7:45:52 AM7/22/06
to Exam Bells !!! - Group for Sem exam preparation
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class TypingTutor extends JFrame
{
JTextArea fieldInput , textToType ;


TypingTutor ()


{
Container c = getContentPane();
c.setLayout(new FlowLayout());

textToType = new JTextArea ("Open source describes practices in
production and development that promote access to the end

product's sources. Some consider it as a philosophy, and others
consider it as a pragmatic methodology. Before open source became
widely adopted,

developers and producers used a variety of phrases to describe the
concept; the term open source gained popularity with the rise of the
Internet and

its enabling of diverse production models, communication paths, and
interactive communities. Subsequently, open source software became the

most prominent face of open source."+

"The open source model can allow for the concurrent use of different
agendas and approaches in production, in contrast with more centralized


models of development such as those typically used in commercial
software companies.",10,50);
textToType .setLineWrap(true);
textToType .setForeground(Color.BLUE );
textToType .setFont(new Font("SansSerif" , Font.BOLD, 15));


fieldInput = new JTextArea(10,50);
fieldInput .setFont(new Font("SansSerif" , Font.BOLD, 15));
fieldInput .setLineWrap(true);
c.add(textToType );
c.add(fieldInput );

}
}

public class TypingTutorTest


{
public static void main(String args[])
{

TypingTutor t1 = new TypingTutor ();
t1.setSize(700,600);
t1.setVisible(true);
t1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

//***************************************************************

Justin

unread,
Jul 22, 2006, 7:51:01 AM7/22/06
to Exam Bells !!! - Group for Sem exam preparation
The above mentiooned program is an emulator for the typing tutor
program ,its only in development condition. so expect more in the future

Message has been deleted

Justin

unread,
Jul 23, 2006, 7:37:15 AM7/23/06
to Exam Bells !!! - Group for Sem exam preparation
/*program to type something in one textfiled and that string appears in
all other textfiels in that frame !!!!!!! in differnet colours*/
//GhostImageTest.java
//Author : justin , 2006

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class GhostImage extends JFrame
{
JTextField fieldName ,fieldGhost1 ,fieldGhost2 ,fieldGhost3
,fieldGhost4 ,fieldGhost5 ,fieldGhost6 ;
JLabel labelEnterName;
String hisName;
Container c ;
String ghostString="";

GhostImage ()
{
c = getContentPane();

c.setLayout(new FlowLayout());
labelEnterName = new JLabel("Enter your name");
c.add(labelEnterName );

fieldName = new JTextField (20);
c.add(fieldName);

fieldGhost1 = new JTextField (20);
fieldGhost1 .setForeground(Color.PINK);
fieldGhost1.setFont(new Font("SansSerif" , Font.BOLD, 17));
c.add(fieldGhost1);

fieldGhost2 = new JTextField (20);
fieldGhost2.setFont(new Font("SansSerif" , Font.BOLD, 17));
fieldGhost2 .setForeground(Color.BLUE);
c.add(fieldGhost2);

fieldGhost3 = new JTextField (20);
fieldGhost3.setFont(new Font("SansSerif" , Font.BOLD, 17));
fieldGhost3.setForeground(Color.CYAN);
c.add(fieldGhost3);

fieldGhost4 = new JTextField (20);
fieldGhost4.setFont(new Font("SansSerif" , Font.BOLD, 17));
fieldGhost4 .setForeground(Color.GREEN);
c.add(fieldGhost4);

fieldGhost5 = new JTextField (20);
fieldGhost5.setFont(new Font("SansSerif" , Font.BOLD, 17));
fieldGhost5 .setForeground(Color.MAGENTA);
c.add(fieldGhost5);

fieldGhost6 = new JTextField (20);
fieldGhost6.setFont(new Font("SansSerif" , Font.BOLD, 17));
fieldGhost6 .setForeground(Color.ORANGE);
c.add(fieldGhost6);


MyKeyAdapter myKey = new MyKeyAdapter ();
fieldName.addKeyListener(myKey);

} //end of constructor

private class MyKeyAdapter extends KeyAdapter
{
public void keyReleased(KeyEvent e)
{

ghostString = ghostString +e.getKeyChar();
fieldGhost1.setText(fieldName.getText() );
fieldGhost2.setText(fieldName.getText() );
fieldGhost3.setText(fieldName.getText());
fieldGhost4.setText(fieldName.getText() );
fieldGhost5.setText(fieldName.getText());
fieldGhost6.setText(fieldName.getText());

} //end ofkeyTyped
} //end of private inner class
} //end of outer class

class GhostImageTest


{
public static void main(String args[])
{

GhostImage g1 = new GhostImage ();
g1.setSize(300,600);
g1.setVisible(true);
g1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}


//***************************************************************************************

melvin

unread,
Jul 23, 2006, 11:39:53 AM7/23/06
to Exam Bells !!! - Group for Sem exam preparation
machooooo,
u r really rokin man... real gr8 ideaz... typin tutor huhhh hmm i too
want to do sumtthin like dis bue wat to do.... nokkikoodaaa njaan ninne
kadathi vettum....
regards,
melvin

Reply all
Reply to author
Forward
0 new messages