compile and run from the Command Prompt
Note: Some files are missing which can be forwarded upon request.
rajneshwar@gmail.com
-----------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.border.*;
import java.io.*;
import java.awt.datatransfer.*;
public class Professional extends JFrame implements ActionListener
{
String software = "Professional Word 2007";
String username = "Rajneshwar Prasad";
private JDesktopPane jdp = new JDesktopPane();
Container c = getContentPane();
JInternalFrame login;
JTextArea textArea;
Color color1 = new Color(170,196,181);
Color color2 = new Color(0,0,0);
Color color3 = new Color(23,14,199);
JPanel loginPanel = new JPanel();
JLabel userLabel = new JLabel("Username");
JLabel passLabel = new JLabel("Password");
JTextField userText = new JTextField(10);
JPasswordField passText = new JPasswordField(10);
JButton submit = new JButton("Submit");
JButton cancel = new JButton("Cancel");
JPanel tool = new JPanel();
Icon newIcon = new ImageIcon("images//new.gif");
JButton newButton = new JButton(newIcon);
Icon openIcon = new ImageIcon("images//new.gif");
JButton openButton = new JButton(openIcon);
Icon saveIcon = new ImageIcon("images//new.gif");
JButton saveButton = new JButton(saveIcon);
JMenuBar jmb = new JMenuBar();
JMenu file = new JMenu("File");
JMenu edit = new JMenu("Edit");
JMenu view = new JMenu("View");
JMenu insert = new JMenu("Insert");
JMenu format = new JMenu("Format");
JMenu tools = new JMenu("Tools");
JMenu table = new JMenu("Table");
JMenu window = new JMenu("Window");
JMenu help = new JMenu("Help");
JMenuItem fnew = new JMenuItem("New...");JMenuItem fopen = new JMenuItem("Open...");
JMenuItem fclose = new JMenuItem("Close");JMenuItem fsave = new JMenuItem("Save");
JMenuItem fsaveas = new JMenuItem("Save As...");JMenuItem fsaveaswebpage = new JMenuItem("Save As Web Page");
JMenuItem fsearch = new JMenuItem("Search...");JMenuItem fversions = new JMenuItem("Versions...");
JMenuItem fwebpagepreview = new JMenuItem("Web Page Preview");JMenuItem fpagesetup = new JMenuItem("Page Setup...");
JMenuItem fprintpreview = new JMenuItem("Print Preview");JMenuItem fprint = new JMenuItem("Print...");
JMenuItem fproperties = new JMenuItem("Properties");JMenuItem fexit = new JMenuItem("Exit");
JMenu fsendto = new JMenu("Send To");
JMenuItem fsmailrecipient = new JMenuItem("Mail Recipient");
JMenuItem fsmailrecipientreview = new JMenuItem("Mail Recipient (for Review)...");
JMenuItem fsmailrecipientattach = new JMenuItem("Mail Recipient (as Attachment)...");
JMenuItem fsroutingrecipient = new JMenuItem("Routing Recipient...");
JMenuItem fsexchangefolder = new JMenuItem("Exchange Folder...");
JMenuItem fsonlinemeeting = new JMenuItem("Online Meeting Participant");
JMenuItem fsfaxrecipient = new JMenuItem("Fax Recipient...");
JMenuItem fsmspowerpoint = new JMenuItem("Microsoft PowerPoint");
JMenuItem eundo = new JMenuItem("Undo");JMenuItem eredo = new JMenuItem("Redo");
JMenuItem ecut = new JMenuItem("Cut");JMenuItem ecopy = new JMenuItem("Copy");
JMenuItem eofficeclipboard = new JMenuItem("Office Clip Board...");JMenuItem epaste = new JMenuItem("Paste");
JMenuItem epastespecial = new JMenuItem("Paste Special...");JMenuItem epasteashyperlink = new JMenuItem("Paste as Hyperlink");
JMenuItem eselectall = new JMenuItem("Select All");JMenuItem efind = new JMenuItem("Find...");
JMenuItem ereplace = new JMenuItem("Replace...");JMenuItem egoto = new JMenuItem("Go To...");
JMenuItem elinks = new JMenuItem("Links..."); JMenuItem eobject = new JMenuItem("Object");
JMenu eclear = new JMenu("Clear");
JMenuItem ecformats = new JMenuItem("Formats");
JMenuItem eccontents = new JMenuItem("Contents Del");
JMenuItem vnormal = new JMenuItem("Normal");JMenuItem vweblayout = new JMenuItem("Web Layout");
JMenuItem vprintlayout = new JMenuItem("Print Layout");JMenuItem voutline = new JMenuItem("Outline");
JMenuItem vtaskpane = new JMenuItem("Task Pane");JMenuItem vruler = new JMenuItem("Ruler");
JMenuItem vdocumentmap = new JMenuItem("Document Map");JMenuItem vheadernfooter = new JMenuItem("Header and Footer");
JMenuItem vfootnotes = new JMenuItem("Footnotes");JMenuItem vmarkup = new JMenuItem("Markup");
JMenuItem vfullscreen = new JMenuItem("Full Screen");JMenuItem vzoom = new JMenuItem("Zoom...");
JMenu vtoolbars = new JMenu("Toolbars");
JCheckBoxMenuItem vtstandard = new JCheckBoxMenuItem("Standard");JCheckBoxMenuItem vtformatting = new JCheckBoxMenuItem("Formating");
JCheckBoxMenuItem vtautotext = new JCheckBoxMenuItem("AutoText");JCheckBoxMenuItem vtcontrol = new JCheckBoxMenuItem("Control Toolbox");
JCheckBoxMenuItem vtdatabase = new JCheckBoxMenuItem("Database");JCheckBoxMenuItem vtdrawing = new JCheckBoxMenuItem("Drawing");
JCheckBoxMenuItem vtforms = new JCheckBoxMenuItem("Forms");JCheckBoxMenuItem vtframes = new JCheckBoxMenuItem("Frames");
JCheckBoxMenuItem vtmailmerge = new JCheckBoxMenuItem("Mail Merge");JCheckBoxMenuItem vtoutline = new JCheckBoxMenuItem("Outlining");
JCheckBoxMenuItem vtpicture = new JCheckBoxMenuItem("Picture");JCheckBoxMenuItem vtreview = new JCheckBoxMenuItem("Reviewing");
JCheckBoxMenuItem vttables = new JCheckBoxMenuItem("Tables and Borders");JCheckBoxMenuItem vtvb = new JCheckBoxMenuItem("Visual Basic");
JCheckBoxMenuItem vtweb = new JCheckBoxMenuItem("Web");JCheckBoxMenuItem vtwebtools = new JCheckBoxMenuItem("Web Tools");
JCheckBoxMenuItem vtwordcount = new JCheckBoxMenuItem("Word Count");JCheckBoxMenuItem vtwordart = new JCheckBoxMenuItem("Word Art");
JMenuItem vtcustomize = new JMenuItem("Customize...");
JMenuItem ibreak = new JMenuItem("Break...");JMenuItem ipagenum = new JMenuItem("Page Numbers...");
JMenuItem idate = new JMenuItem("Date and Time...");JMenuItem ifield = new JMenuItem("Field...");
JMenuItem isymbol = new JMenuItem("Symbol...");JMenuItem icomment = new JMenuItem("Comment");
JMenuItem iwebcomp = new JMenuItem("Web Component...");JMenuItem idiagram = new JMenuItem("Diagram...");
JMenuItem itextbox = new JMenuItem("Text Box");JMenuItem ifile = new JMenuItem("File...");
JMenuItem iobject = new JMenuItem("Object...");JMenuItem ibookmark = new JMenuItem("Bookmark");
JMenuItem ihyperlink = new JMenuItem("Hyperlink...");
JMenu iautotext = new JMenu("AutoText");JMenu iref = new JMenu("Reference");
JMenu ipicture = new JMenu("Picture");
JMenuItem ffont = new JMenuItem("Font...");JMenuItem fparagraph = new JMenuItem("Paragraph...");
JMenuItem fbullets = new JMenuItem("Bullets and Numbering...");JMenuItem fborders = new JMenuItem("Borders and Shading...");
JMenuItem fcolumns = new JMenuItem("Columns...");JMenuItem ftabs = new JMenuItem("Tabs...");
JMenuItem fdropcap = new JMenuItem("Drop Cap...");JMenuItem ftextdir = new JMenuItem("Text Direction...");
JMenuItem fchangecase = new JMenuItem("Change Case...");JMenuItem ftheme = new JMenuItem("Theme...");
JMenuItem fautoformat = new JMenuItem("AutoFormat");JMenuItem fstylenformat = new JMenuItem("Styles and Formatting...");
JMenuItem frevealformat = new JMenuItem("Reveal Formatting");JMenuItem fobject = new JMenuItem("Object...");
JMenu fbackground = new JMenu("Background");JMenu fframes = new JMenu("Frames");
JMenuItem tspelling = new JMenuItem("Spelling and Grammar...");
JMenuItem tfixbroken = new JMenuItem("Fix Broken Text...");
JMenuItem twordcount = new JMenuItem("Word Count...");
JMenuItem tautosum = new JMenuItem("AutoSummrize...");
JMenuItem tspeech = new JMenuItem("Speech");
JMenuItem ttrackchanges = new JMenuItem("Track Changes");
JMenuItem tcomparenmerge = new JMenuItem("Compare and Merge Documents...");
JMenuItem tprotect = new JMenuItem("Protect Document...");
JMenuItem ttoolsweb = new JMenuItem("Tools on the Web...");
JMenuItem ttemplates = new JMenuItem("Templates and Add-Ins");
JMenuItem tautocorrect = new JMenuItem("AutoCorrect Options...");
JMenuItem tcustomize = new JMenuItem("Customize...");
JMenuItem toptions = new JMenuItem("Options...");
JMenu tlanguage = new JMenu("Language");
JMenu tonlinecol = new JMenu("Online Collaboration");
JMenu tletters = new JMenu("Letters and Mailings");
JMenu tmacro = new JMenu("Macro");
JMenuItem tbdraw = new JMenuItem("Draw Table");
JMenuItem tbmerge = new JMenuItem("Merge Cells");
JMenuItem tbsplitcell = new JMenuItem("Split Cells...");
JMenuItem tbsplittable = new JMenuItem("Split Table");
JMenuItem tbautoformat = new JMenuItem("Table AutoFormat...");
JMenuItem tbheading = new JMenuItem("Heading Rows Repeat");
JMenuItem tbsort = new JMenuItem("Sort...");
JMenuItem tbformula = new JMenuItem("Formula...");
JMenuItem tbhidegrid = new JMenuItem("Hide Gridlines...");
JMenuItem tbproperties = new JMenuItem("Table Properties");
JMenu tbinsert = new JMenu("Insert");
JMenu tbdelete = new JMenu("Delete");
JMenu tbselect = new JMenu("Select");
JMenu tbautofit = new JMenu("AutoFit");
JMenu tbconvert = new JMenu("Convert");
JMenuItem wnew = new JMenuItem("New Window");
JMenuItem warrange = new JMenuItem("Arrange All");
JMenuItem wsplit = new JMenuItem("Split");
JMenuItem hmsword = new JMenuItem("Microsoft Word Help");
JMenuItem hoffassist = new JMenuItem("Show the Office Assistant");
JMenuItem hwhats = new JMenuItem("What's This?");
JMenuItem hoffice = new JMenuItem("Office on the Web");
JMenuItem hactivate = new JMenuItem("Activate Product...");
JMenuItem hwperfect = new JMenuItem("WordPerfect Help...");
JMenuItem hdetect = new JMenuItem("Detect and Repair...");
JMenuItem habout = new JMenuItem("About Microsoft Word");
Clipboard clipboard = getToolkit().getSystemClipboard();
NewWindow nw = new NewWindow();
int win = 0;
public Professional()throws Exception{
setTitle(software+" -- Rajneshwar Prasad");
Splash sp = new Splash(1000);
sp.showSplash();
jdp.setDragMode(5);
jdp.setAutoscrolls(true);
jdp.setToolTipText(""+software+"");
jdp.setBackground(color1);
jdp.setOpaque(true);
login = new JInternalFrame("Please Log-in",true,true,true,true);
UIManager.put("ToolTip.foreground",new ColorUIResource(Color.blue));
UIManager.put("ToolTip.background",new ColorUIResource(Color.white));
login.setToolTipText("
if unable to Log-in
submit.addActionListener(this);
cancel.addActionListener(this);
loginPanel.add(userLabel);loginPanel.add(userText);
//loginPanel.add(passLabel);loginPanel.add(passText);
loginPanel.add(submit);loginPanel.add(cancel);
login.getContentPane().add(loginPanel,BorderLayout.CENTER);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
login.setLocation(screen.width/2-100,screen.height/2-150);
login.setSize(200,130);
login.setResizable(false);
login.setMaximizable(false);
login.setClosable(false);
//Rectangle rect = new Rectangle(screen.width/2-100,screen.height/2-150,150,200);
//login.setBounds(rect);
login.setSelected(true);
login.toFront();
jdp.add(login);
login.setVisible(true);
c.add(jdp);
}
public void actionPerformed(ActionEvent ae){
if (ae.getSource()==submit){
username = userText.getText();
if(!(username.equals("")))
setTitle(software+" -- "+username);
login.setVisible(false);
jmb.add(file);jmb.add(edit);jmb.add(view);
jmb.add(insert);jmb.add(format);jmb.add(tools);
jmb.add(table);jmb.add(window);jmb.add(help);
fileMenu();editMenu();viewMenu();insertMenu();formatMenu();
toolsMenu(); tableMenu(); windowMenu(); helpMenu();
setJMenuBar(jmb);
JToolBar jtb = new JToolBar(software);
newButton.addActionListener(this);openButton.addActionListener(this);saveButton.addActionListener(this);
newButton.setToolTipText("New");
jtb.add(newButton);
openButton.setToolTipText("Open");
jtb.add(openButton);
saveButton.setToolTipText("Save");
Border m_lowered = new BevelBorder(BevelBorder.RAISED);
//saveButton.setBorder(m_lowered);
jtb.add(saveButton);
c.add(jtb,BorderLayout.NORTH);
win++;
nw.createWindow(jdp,win,textArea);
}
if(ae.getSource()==fnew||ae.getSource()==newButton){
win++;
nw.createWindow(jdp,win,textArea);
}
if(ae.getSource()==fopen||ae.getSource()==openButton){
JFileChooser jfc = new JFileChooser();
int ret = jfc.showOpenDialog(this);
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (ret == JFileChooser.APPROVE_OPTION) {
File file = jfc.getSelectedFile();
System.out.println("Opening: " + file.getName() + "." );
} else {
System.out.println("Open command cancelled by user." );
}
}
if(ae.getSource()==fclose){
nw.closeWindow();
}
if(ae.getSource()==fsave||ae.getSource()==fsaveas||ae.getSource()==saveButton){
JFileChooser jfc = new JFileChooser();
int ret = jfc.showSaveDialog(this);
}
if(ae.getSource()==fexit){System.exit(0);}
if(ae.getSource()==ecopy){
StringSelection data = new StringSelection(textArea.getText());
clipboard.setContents(data, data);
}
if(ae.getSource()==epaste){
Transferable clipData = clipboard.getContents(this);
String s;
try {
s = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
}catch (Exception ex) {
s = ex.toString();
}
textArea.setText(s);
}
}
public static void main(String[] args)throws Exception
{
Professional p = new Professional();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
p.setSize(screen.width,screen.height-50);
p.show();
p.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
p.setIconImage(Toolkit.getDefaultToolkit().getImage("images//icon.gif"));
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
}
public void fileMenu(){
fnew.addActionListener(this);fopen.addActionListener(this);
fclose.addActionListener(this);fsave.addActionListener(this);
fsaveas.addActionListener(this);fsaveaswebpage.addActionListener(this);
fsearch.addActionListener(this);fwebpagepreview.addActionListener(this);
fversions.addActionListener(this);fpagesetup.addActionListener(this);
fprintpreview.addActionListener(this);fprint.addActionListener(this);
fproperties.addActionListener(this);fexit.addActionListener(this);
fnew.setIcon(newIcon);
fopen.setIcon(newIcon);
fsave.setIcon(newIcon);
file.add(fnew);file.add(fopen);file.add(fclose);file.addSeparator();
file.add(fsave);file.add(fsaveas);file.add(fsaveaswebpage);file.add(fsearch);file.addSeparator();
file.add(fversions);file.addSeparator();
file.add(fwebpagepreview);file.addSeparator();
file.add(fpagesetup);file.add(fprintpreview);file.add(fprint);file.addSeparator();
file.add(fsendto);file.add(fproperties);file.addSeparator();
file.add(fexit);
fsmailrecipient.addActionListener(this); fsmailrecipientreview.addActionListener(this);
fsmailrecipientattach.addActionListener(this);fsroutingrecipient.addActionListener(this);
fsexchangefolder.addActionListener(this);fsonlinemeeting.addActionListener(this);
fsfaxrecipient.addActionListener(this);fsmspowerpoint.addActionListener(this);
fsendto.add(fsmailrecipient); fsendto.add(fsmailrecipientreview);
fsendto.add(fsmailrecipientattach); fsendto.add(fsroutingrecipient);
fsendto.add(fsexchangefolder); fsendto.add(fsonlinemeeting);
fsendto.add(fsfaxrecipient); fsendto.addSeparator();
fsendto.add(fsmspowerpoint);
}
public void editMenu(){
eundo.addActionListener(this);eredo.addActionListener(this);
ecut.addActionListener(this);ecopy.addActionListener(this);
eofficeclipboard.addActionListener(this);epaste.addActionListener(this);
epasteashyperlink.addActionListener(this);eselectall.addActionListener(this);
efind.addActionListener(this);ereplace.addActionListener(this);
egoto.addActionListener(this);elinks.addActionListener(this);
eobject.addActionListener(this);
edit.add(eundo);edit.add(eredo);edit.addSeparator();
edit.add(ecut);edit.add(ecopy);edit.add(eofficeclipboard);edit.add(epaste);edit.add(epastespecial);edit.add(epasteashyperlink);edit.addSeparator();
edit.add(eclear);edit.add(eselectall);edit.addSeparator();
edit.add(efind);edit.add(ereplace);edit.add(egoto);edit.addSeparator();
edit.add(elinks);edit.add(eobject);
ecformats.addActionListener(this); eccontents.addActionListener(this);
eclear.add(ecformats); eclear.add(eccontents);
}
public void viewMenu(){
view.add(vnormal);view.add(vweblayout);view.add(vprintlayout);view.addSeparator();
view.add(vtoolbars);
view.add(voutline); view.add(vtaskpane);view.add(vruler);view.add(vdocumentmap);view.addSeparator(); view.add(vheadernfooter);
view.add(vfootnotes);view.add(vmarkup);view.addSeparator();
view.add(vfullscreen); view.add(vzoom);
vtoolbars.add(vtstandard); vtoolbars.add(vtformatting);vtoolbars.add(vtstandard);
vtoolbars.add(vtformatting);vtoolbars.add(vtautotext); vtoolbars.add(vtcontrol);
vtoolbars.add(vtdatabase); vtoolbars.add(vtdrawing); vtoolbars.add(vtforms);
vtoolbars.add(vtframes); vtoolbars.add(vtmailmerge); vtoolbars.add(vtoutline);
vtoolbars.add(vtpicture); vtoolbars.add(vtreview); vtoolbars.add(vttables);
vtoolbars.add(vtvb); vtoolbars.add(vtweb); vtoolbars.add(vtwebtools);
vtoolbars.add(vtwordcount); vtoolbars.add(vtwordart);
vtoolbars.addSeparator();
vtoolbars.add(vtcustomize);
}
public void insertMenu(){
insert.add(ibreak); insert.add(ipagenum);
insert.add(idate); insert.add(ifield); insert.add(iautotext);
insert.add(isymbol); insert.add(icomment); insert.addSeparator();
insert.add(iref); insert.add(iwebcomp); insert.addSeparator();
insert.add(ipicture); insert.add(idiagram); insert.add(itextbox);
insert.add(ifile); insert.add(iobject); insert.add(ibookmark);
insert.add(ihyperlink);
}
public void formatMenu(){
format.add(ffont); format.add(fparagraph);
format.add(fbullets);format.add(fborders);
format.add(fcolumns);format.add(ftabs);
format.add(fdropcap);format.add(ftextdir);
format.add(fchangecase);format.addSeparator();
format.add(ftheme);
format.add(fautoformat);format.add(fstylenformat);
format.add(frevealformat);format.add(fobject);
JMenu fbackground = new JMenu("Background");
JMenu fframes = new JMenu("Frames");
}
public void toolsMenu(){
tools.add(tspelling); tools.add(tlanguage); tools.add(tfixbroken);
tools.add(twordcount); tools.add(tautosum);
tools.add(tspeech); tools.addSeparator(); tools.add(ttrackchanges);
tools.add(tcomparenmerge); tools.add(tprotect); tools.add(tonlinecol); tools.addSeparator();
tools.add(tletters); tools.addSeparator(); tools.add(ttoolsweb); tools.add(tmacro);
tools.add(ttemplates); tools.add(tautocorrect); tools.add(tcustomize);
tools.add(toptions);
}
public void tableMenu(){
table.add(tbdraw); table.addSeparator(); table.add(tbinsert); table.add(tbdelete);
table.add(tbselect); table.add(tbmerge);
table.add(tbsplitcell); table.add(tbsplittable); table.addSeparator();
table.add(tbautoformat); table.add(tbautofit); table.add(tbheading); table.addSeparator();
table.add(tbconvert); table.add(tbsort); table.add(tbformula);
table.add(tbhidegrid); table.addSeparator(); table.add(tbproperties);
}
public void windowMenu(){
window.add(wnew); window.add(warrange); window.add(wsplit);
window.addSeparator();
}
public void helpMenu(){
help.add(hmsword); help.add(hoffassist);
help.addSeparator(); help.add(hwhats);
help.add(hoffice); help.add(hactivate);
help.add(hwperfect); help.addSeparator();
help.add(hdetect); help.addSeparator();
help.add(habout);
}
}
1 comment:
u seem guru in java boss
Post a Comment