Regarding applets

Hi,
I am Amarnath doing my final year in under-grad.. My Problem is......
I have 1 main applet..and ..4 sub-applets.. And this main Applet contain 4 buttons.. Iwould like t know whether if i click on a button i want that sub-applet to come..
For example, a student database information application
My main applet consists of 3 buttons 1)insert,2)delete 3)update in Main.java
and i have 4 applest insertStud.java,deleteStud,java,updateStud.java..
-----now when i click insert button on main.java i want the insertStud.java to display..Is it possible t do..If possible can u tell me how either directly or as a reference to any link..

What you are asking is not clear. This page
http://java.sun.com/docs/books/tutorial/deployment/applet/iac.html
has an example of one applet communicating to another (Which isn't working because Sun has misconfigured the website. You'll need to download the Sender and Receiver programs, and compile and run them in your computer.)
If this isn't what you are trying to do, then maybe you can make a better explanation of your objective.

Similar Messages

  • Question regarding Applet and JVM

    Hi all!
    I'm working on an applet now and it's been working quite fine, just that when I run the same applet on different tab in a single browser window, it'll get some error.
    But if I run the applets in different windows, it'll be fine.
    So I'd like to know how does JVM handle the execution of applet?
    What is the difference between:
    - how JVM handles multiple applet in different-tab-in-single-browser and
    - how JVM handles multiple applet in different browser?
    Any help is greatly appreciated :)
    Thanks in advance ^^

    Sounds like you're using static fields. Not a good idea in applets because...
    What is the difference between:
    - how JVM handles multiple applet in different-tab-in-single-browser and
    - how JVM handles multiple applet in different browser?
    ...that's entirely up to the browser. Actually, your question's slightly misconstrued. What you should really ask is,
    What is the difference between:
    - how the browser spawns JVMs in different-tab-in-single-browser and
    - how the browser spawns JVMs in different browser?
    Either way, it's out of your hands. Which is why you're going to have to be very careful about using statics: if you use them for state information then another applet can trash them; if you use them for inter-applet communication you might not reach one applet from another.

  • Help needed regarding applets

    hi all,
    i wans to write to a file which is in remote server using applet i m using secured applets.plz sujjest me

    What do you mean "write to a file"?
    Generally, the answer to a question like this is "write some server-side functionality that takes client input and handles it appropriately", but that's not always the answer.

  • Help regarding applet for querying client's MAC?

    Please help with an applet and java code that uses Runtime.getRuntime().exec("ipconfig -all") and gets the client's machine MAC address?
    If any one already worked with applets for querying client mahchine MAC , please give me a solution.

    remus.dragos wrote:
    vasu.mtech wrote:
    I am giving an explanation where I want this:
    We have an application, where user will be given a specific machine(with one MAC) and have to login from there only. If he tries to login from different machine with same user id, we should throw an error message. That's concept. We know that this reduces/kills operatability of the user from different machines.
    But we shouldn't allow the user operating from diffrent machines.What happens if the admins NIC burns? And he gets a news one? He can't log in until you manually change his
    MAC in the database ???Database? That's not secure!
    It has to be hardcoded into the exe (guess what the kid's next question will be?).

  • Regarding Applet

    Hi Friends !!!!!!
    how to conect a database by using Applet.Its giving access denied error.if any body knows.please help me.
    thanx in advance.............prabhakar.

    You mean accessing a database on a different machine?? it's not possible in Applets unless they are singed. Read the applet security concept in Java tutorial at java.sun.com
    /Sreenivasa Kumar Majji.
    Hi Friends !!!!!!
    how to conect a database by using Applet.Its giving
    access denied error.if any body knows.please help me.
    thanx in advance.............prabhakar.

  • URGENT regarding applet ejb communication

    Following is my applet code
    i get the inital context but
    it get stuck up at this point
    Hello home interface
    Object boundObject = context.lookup("java:comp/env/ejb/HelloHome");
    This is the place wher eit hangs
    i have even given acces right in orion-application.xml
    pl help
    ---Applet Code---
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Date;
    import java.util.Properties;
    import javax.naming.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.rmi.PortableRemoteObject;
    import hello.ejb.Hello;
    import hello.ejb.HelloHome;
    public class AppletClient extends JApplet {
    boolean isStandalone = false;
    JLabel jLabel1 = new JLabel();
    BorderLayout borderLayout1 = new BorderLayout();
    public void init() {
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception
    hello.ejb.Hello _hello;
    hello.ejb.HelloHome helloHome;
    // Get the initial JNDI context using our settings
    this.getContentPane().setLayout(borderLayout1);
    this.setSize(new Dimension(400, 400));
    jLabel1.setText("Display");
    this.getContentPane().add(jLabel1, BorderLayout.CENTER);
    //added new code
    try
    System.out.println("Method call after inital before");
    Context context = getInitialContext();
    System.out.println("Method call after inital");
    // Get a reference to the Hello home interface
    Object boundObject = context.lookup("java:comp/env/ejb/HelloHome");
    System.out.println("Method call after bound");
    helloHome = (HelloHome) PortableRemoteObject.narrow(boundObject,hello.ejb.HelloHome.class);
    System.out.println("Method call");
    // Get a reference to a Hello instance
    _hello = helloHome.create();
    jLabel1.setText(_hello.sayHello());
    catch (Throwable exception)
    throw new Exception("Error " + exception.toString());
    //ends
    public static Context getInitialContext() throws javax.naming.NamingException
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
    p.put(Context.PROVIDER_URL,"ormi://localhost/hello-planet");
    p.put(Context.SECURITY_PRINCIPAL,"admin");
    p.put(Context.SECURITY_CREDENTIALS,"gateway");
    p.put(Context.DNS_URL,"http://localhost:8888/hello-planet");
    return new javax.naming.InitialContext(p);
    null

    I have got a solution for that problem :
    I have a WinTel/NT Client with installed JRE 1.3.1 . Go to the Conrol Panel, Java Plugin ,first tab-folder "standard" , SET runtime parameter =
    -java.security.manager -Djava.security.policy=<URL>
    where <URL> links to a file which must contain :
    grant {
    permission java.security.AllPermission;
    Thats all. works for me, but i dont like this solution because you have to do these
    settings on each client using your applet and it'll be a big security leak. Give it a try :-((

  • Querry regarding applets and application

    hello sir,
    i am in great trouble! please help me! see i want to know that is it possible that i can create an applet from application! in the sense i am studying in a computer institue and we are told to make a project on notepad! we are told to make a project through java! i have prepared it! but the question in my mind is that i have also created an applet which shows a clock with date and time! but the notepad i have created is an application and in that i have added menu bars in which there is a sub menu called "date/ time". i want that when ever some one clicks on date/ time tab then it should show the clock! i am confused! i cant get any thing as solution please help me! i am in great trouble! i want to submit my notepad by this thursday 2nd aug! please help me! i cant get anyone to help!
    i am also mailing my whole code! please rectify if any present!
    here is the code: for notepad
    import java.awt.*;
    import java.applet.*;
    import java.awt.font.*;
    import javax.swing.event.*;
    import javax.swing.colorchooser.*;
    import java.awt.print.*;
    import java.awt.event.*;
    import javax.swing.text.*;
    import javax.swing.undo.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    public class Notepad implements KeyListener,ActionListener, ItemListener, Runnable
         static JFrame frame;
         static JTextArea txtArea;
         JScrollPane scrollPane;
         JMenuBar menuBar;
         JMenu fileMenu, editMenu, toolsMenu, aboutMenu;
         JMenuItem mNew, popNew, mDelete, mOpen, mSave, mSaveAs, mPrint, mClose, mExit, mCut, popCut, mCopy, popCopy, mPaste, popPaste,popSelectAll, mSelectAll, mDateTime, mAboutNotepad;
         JPanel panel;
         JPopupMenu popMenu;
         JCheckBoxMenuItem chkWordwrap;
         JComboBox cmbFontSize, cmbFont ;
         JToolBar toolbar;
         JButton btnSave, btnNew, btnOpen, btnCut, btnCopy, btnPaste;
         static boolean textChanged = false;
         static String title = " Notepad - by Vicky Saini";
         private static Vector fonts;
         static GraphicsEnvironment env;
         String fontChoice = "Font Choice";
         Integer FontSize ;
         Hashtable actions;
         DefaultStyledDocument document;
         Thread threadTime;
    // static AudioClip clockbeep;     
    public void help()
              JFrame frame= new JFrame();
              JOptionPane op = new JOptionPane(" Vicky Saini's NotePad 1.0, "
                                                                + "\n" + "Created by V I C K Y S A I N I \n"
                                                                + "Batch No: 1103 - SMA007 \n"
                                                                + "Developed under Guidence of Ashish Thakkar \n" + "\n" + "For support information Contact:\n"
                                                                +"[email protected] \n" + "\n"
    + " Copyright 2001-2005 SainiSoft\n"
                                                                     + "Download Version" + " \n"
                                                                     + "All Right Reserved \n" ,
    JOptionPane.INFORMATION_MESSAGE,JOptionPane.CLOSED_OPTION,new ImageIcon("vickyN.jpg"));
                   JDialog dialog = op.createDialog(frame,"About This Notepad");
                   dialog.setSize(450,350);
                   dialog.setResizable(false);
                   dialog.show();          
         public static void main(String args[])
              //clockbeep=getAudioClip(getDocumentBase(),"clockbell.au");     
              //clockbeep.play();
              JOptionPane.showMessageDialog(new JFrame(),"Wel-Come to Vicky's Notepad");
              Notepad notepad = new Notepad();
              notepad.createNotepad();
              txtArea.setRequestFocusEnabled(true);
              txtArea.requestFocus();
              //clockbeep.stop();
         public void createNotepad()
              frame = new JFrame(title);
              frame.setSize(600, 550);
              document = new DefaultStyledDocument();
              txtArea = new JTextArea(document);
              createActionTable(txtArea);
              txtArea.addKeyListener(this);
              scrollPane = new JScrollPane(txtArea);
              menuBar = new JMenuBar();
              frame.setJMenuBar(menuBar);
              createMenu(menuBar);
              panel = new JPanel();
              panel.setLayout(new BorderLayout());
              toolbar = new JToolBar();
              addButton(toolbar);
              panel.add(toolbar, BorderLayout.NORTH);
              frame.addWindowListener(new AppCloser());
              popMenu = new JPopupMenu();
              popMenu.setVisible(true);
              popMenu.setInvoker(scrollPane);
              addpopMenuItem(popMenu);
              MouseListener popupListener = new PopupListener();
              txtArea.addMouseListener(popupListener);
              scrollPane.addMouseListener(popupListener);
              threadTime = new Thread();
              threadTime.start();
              txtArea.setCursor(Cursor.getDefaultCursor());
              try
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch(Exception exc)
                   System.err.println("Error loading L&F: " + exc);
              panel.add(scrollPane, BorderLayout.CENTER);          
              frame.getContentPane().add(panel);
              frame.setVisible(true);     
         public String currentTime()
              Date currentDate = new Date();
              GregorianCalendar gc = new GregorianCalendar();
              gc.setTime(currentDate);
              String year = " " + gc.get(Calendar.YEAR);
              String month = year + "/" + gc.get(Calendar.MONTH);
              String day = month + "/" + gc.get(Calendar.DATE);
              String hour = day + " " + gc.get(Calendar.HOUR);
              String min = hour + ":" + gc.get(Calendar.MINUTE);
              String sec = min + ":" + gc.get(Calendar.SECOND);
              String milli = sec + "." + gc.get(Calendar.MILLISECOND);
              return milli;
         public void run()
              try
                   for(;;)
                        threadTime.sleep(1);
                        currentTime();
              catch(Exception e)
         public void addpopMenuItem(JPopupMenu popMenu)
              popNew = new JMenuItem(" New ");
              popMenu.add(popNew);
              popNew.addActionListener(this);
              popMenu.addSeparator();
              popCut = new JMenuItem(" Cut ");
              popMenu.add(popCut);
              popCut.addActionListener(this);
              popCopy = new JMenuItem(" Copy ");
              popMenu.add(popCopy);
              popCopy.addActionListener(this);
              popPaste = new JMenuItem(" Paste ");
              popMenu.add(popPaste);
              popPaste.addActionListener(this);
              popMenu.addSeparator();
              popSelectAll = new JMenuItem(" Select All ");
              popMenu.add(popSelectAll);
              popSelectAll.addActionListener(this);     
         public void createMenu(JMenuBar menuBar)
              fileMenu = new JMenu(" File ");
              fileMenu.setMnemonic('F');
              menuBar.add(fileMenu);
              editMenu = new JMenu(" Edit ");
              editMenu.setMnemonic('E');
              menuBar.add(editMenu);
              toolsMenu = new JMenu(" Tools ");
              toolsMenu.setMnemonic('T');
              menuBar.add(toolsMenu);
              aboutMenu = new JMenu(" About ");
              aboutMenu.setMnemonic('A');
              menuBar.add(aboutMenu);
              mNew = new JMenuItem(" New ");
              fileMenu.add(mNew);
              mNew.addActionListener(this);
              mNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK));
              mOpen = new JMenuItem(" Open ");
              fileMenu.add(mOpen);
              mOpen.addActionListener(this);
              mOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
              mClose = new JMenuItem(" Close ");
              fileMenu.add(mClose);
              mClose.addActionListener(this);
              fileMenu.addSeparator();
              mSave = new JMenuItem(" Save ");
              fileMenu.add(mSave);
              mSave.addActionListener(this);
              mSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
              mSaveAs = new JMenuItem(" SaveAs ");
              fileMenu.add(mSaveAs);
              mSaveAs.addActionListener(this);
              fileMenu.addSeparator();
              mPrint = new JMenuItem(" Print.... ");
              fileMenu.add(mPrint);
              mPrint.addActionListener(this);
              mPrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK));
              mExit = new JMenuItem(" Exit ");
              fileMenu.add(mExit);
              mExit.addActionListener(this);
              mExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.ALT_MASK));
              editMenu.addSeparator();
              mCut = new JMenuItem(" Cut ");
              editMenu.add(mCut);
              mCut.addActionListener(this);
              mCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK));
              mCopy = new JMenuItem(" Copy ");
              editMenu.add(mCopy);
              mCopy.addActionListener(this);
              mCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK));
              mPaste = new JMenuItem(" Paste ");
              editMenu.add(mPaste);
              mPaste.addActionListener(this);
              mPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK));          
              mDelete = new JMenuItem(" Delete ");
              mDelete.addActionListener(this);
              editMenu.add(mDelete);
              editMenu.addSeparator();
              mSelectAll = new JMenuItem(" Select All ");
              editMenu.add(mSelectAll);
              mSelectAll.addActionListener(this);
              mSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK));          
              toolsMenu.addSeparator();
              chkWordwrap = new JCheckBoxMenuItem(" WordWrap ");
              toolsMenu.add(chkWordwrap);
              chkWordwrap.addItemListener(this);
              toolsMenu.addSeparator();          
              mDateTime = new JMenuItem(" Date/Time ");
              toolsMenu.add(mDateTime);
              mDateTime.addActionListener(this);
              mDateTime.setAccelerator(KeyStroke.getKeyStroke("F5"));
              mAboutNotepad = new JMenuItem(" About Notepad ");
              aboutMenu.add(mAboutNotepad);
              mAboutNotepad.addActionListener(this);
         void addButton(JToolBar toolbar)
              btnOpen = new JButton(new ImageIcon("open.gif"));          
              btnOpen.setToolTipText("Open document");
              btnOpen.addActionListener(this);
              toolbar.add(btnOpen);
              btnOpen.setRequestFocusEnabled(false);
              btnOpen.transferFocus();
              btnNew = new JButton(new ImageIcon("new.gif"));     
              btnNew.setToolTipText("New Document ");
              btnNew.addActionListener(this);
              toolbar.add(btnNew);
              btnNew.setRequestFocusEnabled(false);
              btnNew.transferFocus();
              btnSave = new JButton(new ImageIcon("save.gif"));          
              btnSave.setToolTipText("Save document ");
              btnSave.addActionListener(this);
              toolbar.add(btnSave);
              btnSave.setRequestFocusEnabled(false);
              btnSave.transferFocus();
              toolbar.addSeparator();
              btnCut = new JButton(new ImageIcon("cut.gif"));          
              btnCut.setToolTipText("Cut selection");
              btnCut.addActionListener(this);
              toolbar.add(btnCut);
              btnCut.setRequestFocusEnabled(false);
              btnCut.transferFocus();
              btnCopy = new JButton(new ImageIcon("copy.gif"));          
              btnCopy.setToolTipText("Copy selection ");
              btnCopy.addActionListener(this);
              toolbar.add(btnCopy);
              btnCopy.setRequestFocusEnabled(false);
              btnCopy.transferFocus();
              btnPaste = new JButton(new ImageIcon("paste.gif"));
              btnPaste.setToolTipText("Paste selection ");
              toolbar.add(btnPaste);
              btnPaste.addActionListener(this);
              btnPaste.setRequestFocusEnabled(false);
              btnPaste.transferFocus();
              toolbar.addSeparator();
              env = GraphicsEnvironment.getLocalGraphicsEnvironment();
              String lsFonts[] = env.getAvailableFontFamilyNames();
              cmbFont = new JComboBox();
              cmbFont.setBackground(Color.white);
                   for (int i = 0; i < lsFonts.length; i++)
                        cmbFont.addItem(lsFonts);
              cmbFont.addItemListener(this);
              cmbFont.setMaximumRowCount(15);
              toolbar.add(cmbFont);
                   cmbFontSize = new JComboBox();
                   cmbFontSize.addItemListener(this);
                   cmbFontSize.setBackground(Color.white);
                   cmbFontSize.setRequestFocusEnabled(false);
                   for (int i = 8; i < 36; i+=2)
                             cmbFontSize.addItem(String.valueOf(i));
                             cmbFontSize.setSelectedItem("12");
              toolbar.add(cmbFontSize);
              toolbar.addSeparator();
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == mNew || e.getSource() == btnNew || e.getSource() == popNew)
                   if(textChanged)
                        int option = message();
                        if(option == 0)
                             new Save();
                             frame.setTitle(title);
                             txtArea.setText("");
                             txtArea.addKeyListener(this);
                             textChanged = false;
                        else if(option == 1)
                             frame.setTitle(title);
                             txtArea.setText("");
                             txtArea.addKeyListener(this);
                             textChanged = false;
                        else if(option == 2)
                             return;
                   else
                        frame.setTitle(title);
                        txtArea.setText("");
                        txtArea.addKeyListener(this);
                        textChanged = false;
              else if(e.getSource() == mOpen || e.getSource() == btnOpen)
                   if(textChanged)
                        int option = message();
                        if(option == 0)
                             new Save();
                             new Open();
                             txtArea.addKeyListener(this);
                             textChanged = false;
                        else if(option == 1)
                             new Open();
                             txtArea.addKeyListener(this);
                             textChanged = false;
                        else if(option == 2)
                             return;
                   else
                        new Open();
                        txtArea.addKeyListener(this);
                        textChanged = false;
              else if(e.getSource() == mSave || e.getSource() == btnSave)
                   new Save();
                   txtArea.addKeyListener(this);
                   textChanged = false;
              else if(e.getSource() == mSaveAs)
                   new SaveAs();
              else if(e.getSource() == mPrint)
                   PrinterJob printJob = PrinterJob.getPrinterJob();
                   PageFormat type = printJob.pageDialog(printJob.defaultPage());
                   Book bk = new Book();
                   printJob.setPageable(bk);
                   if(printJob.printDialog())
                        try
                             printJob.print();
              catch (Exception ex)
              else if(e.getSource() == mClose)
                   if(textChanged)
                        int option = message();
                        if(option == 0)
                             new Save();
                             frame.setTitle(title);
                             txtArea.setText("");
                             txtArea.addKeyListener(this);
                             textChanged = false;
                        else if(option == 1)
                             frame.setTitle(title);
                             txtArea.setText("");
                             txtArea.addKeyListener(this);
                             textChanged = false;               
                        else if(option == 2)
                             return;
                   else
                        frame.setTitle(title);
                        txtArea.setText("");
                        txtArea.addKeyListener(this);
                        textChanged = false;
              else if(e.getSource() == mExit )
                   if(textChanged)
                        int option = message();
                        if(option == 0)
                             new Save();
                             JOptionPane.showMessageDialog(new JFrame(),"OH!!!please dont leave me!");
                             System.exit(1);
                        else if(option == 1)
                             JOptionPane.showMessageDialog(new JFrame(),"OH!!!please dont leave me!");
                             System.exit(1);
                        else if(option == 2)
                             return;
                   else
                        JOptionPane.showMessageDialog(new JFrame(),"OH!!!please dont leave me!");
                        System.exit(1);
              else if(e.getSource() == mCut || e.getSource() == btnCut || e.getSource() == popCut)
                   txtArea.cut();
                   textChanged = true;
              else if(e.getSource() == mCopy || e.getSource() == btnCopy || e.getSource() == popCopy)
              {     txtArea.copy();}
              else if(e.getSource() == mPaste || e.getSource() == btnPaste || e.getSource() == popPaste)
                   txtArea.paste(); textChanged = true;
              else if(e.getSource() == mDelete)
                   txtArea.replaceSelection(null);     textChanged = true;
              else if(e.getSource() == mDateTime )
                   txtArea.insert(currentTime(), txtArea.getCaretPosition());
                   textChanged = true;
              else if(e.getSource() == mAboutNotepad)
                   help();
              public void itemStateChanged(ItemEvent ie)
              if(ie.getSource() == chkWordwrap)
                   if(chkWordwrap.getState())
                   {     txtArea.setLineWrap(true);     }
                   else
                   {     txtArea.setLineWrap(false);}
              else if(ie.getSource() == cmbFont)
                   fontChoice = (String)cmbFont.getSelectedItem();
              else if(ie.getSource() == cmbFontSize)
                   FontSize = new Integer((String)cmbFontSize.getSelectedItem());
              txtArea.setFont(new Font(fontChoice,Font.PLAIN, FontSize.intValue()));
              public void keyTyped(KeyEvent ke)
              textChanged = true;
              mSave.setEnabled(true);
              btnSave.setEnabled(true);
              mSaveAs.setEnabled(true);
              txtArea.removeKeyListener(this);
         public void keyPressed(KeyEvent ke)
         public void keyReleased(KeyEvent ke)
         public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
              if (pi >= 1)
                   return Printable.NO_SUCH_PAGE;
              return Printable.PAGE_EXISTS;
         final static int message()
              JFrame frameMessage = new JFrame();
              Object message = "The text in the file has changed........Do u want to save the changes?";
              return JOptionPane.showConfirmDialog(frameMessage, message, " Save ", JOptionPane.YES_NO_CANCEL_OPTION);
         protected final class AppCloser extends WindowAdapter
              public void windowClosing(WindowEvent e)
                   if(textChanged)
                        int option = message();
                        if(option == 0)
                             new Save();
                             JOptionPane.showMessageDialog(new JFrame(),"OH!!!please dont leave me!");
                             System.exit(1);
                        else if(option == 1)
                             JOptionPane.showMessageDialog(new JFrame(),"OH!!!please dont leave me!");
                             System.exit(1);
                        else if(option == 2)
                             return;
                   else
                        JOptionPane.showMessageDialog(new JFrame(),"OH!!!please dont leave me!");
                        System.exit(1);
         class PopupListener extends MouseAdapter
              public void mousePressed(MouseEvent e)
              {     showPopup(e);     }
              public void mouseReleased(MouseEvent e)
              {          showPopup(e);     }
              private void showPopup(MouseEvent e)
                   if(e.isPopupTrigger())
                        popMenu.show(e.getComponent(), e.getX(), e.getY());
         private void createActionTable(JTextArea textArea)
              actions = new Hashtable();
              Action[] actionsArray = txtArea.getActions();
              for (int i = 0; i < actionsArray.length; i++)
                   Action a = actionsArray[i];
                   actions.put(a.getValue(Action.NAME), a);
         private Action getActionByName(String name)
    return(Action)(actions.get(name));
         class Open
              public Open()
                   JFrame frame;
                   FileDialog openFile;
                   frame = new JFrame();
                   frame.setLocation(150,150);
                   openFile = new FileDialog(frame, " Open ", 0);
                   openFile.show();
                   String dirName = openFile.getDirectory();
                   String fileName = openFile.getFile();
                   if(dirName == null || fileName == null)
                   {     return;     }
                   else
                        try
                             FileInputStream readFile = new FileInputStream(dirName + fileName);
                             int fileSize = readFile.available();
                             byte inBuff[] = new byte[fileSize];
                             int readByte = readFile.read(inBuff, 0, fileSize);
                             readFile.close();
                             Notepad.txtArea.setText(new String(inBuff));
                             Notepad.frame.setTitle(openFile.getFile());
                        catch(Exception e)
                             Object warn = "Unable to open";
                             JOptionPane.showMessageDialog(new JFrame(), warn, "Warning.....", JOptionPane.WARNING_MESSAGE );
         class Save
              JFrame frameSave;
              FileDialog saveFile;
              String fileName = frame.getTitle();
              public Save()
                   if(title == fileName)
                        frameSave = new JFrame();
                        frameSave.setLocation(150,150);
                        saveFile = new FileDialog(frameSave, " Save ", 1);
                        saveFile.show();
                        fileName = saveFile.getDirectory() + saveFile.getFile();
                        if(fileName.length() == 8)
                             return;
                        else
                             Notepad.frame.setTitle(saveFile.getFile());
                   try
                        FileOutputStream writeFile = new FileOutputStream(fileName);
                        System.out.flush();
                        String input = Notepad.txtArea.getText();
                        for (int n = 0; n < input.length(); n++ )
                             writeFile.write(input.charAt(n) );
                        writeFile.close();
                   catch (Exception e)
                        Object warn = "Unable to save file.........";
                        JOptionPane.showMessageDialog(new JFrame(), warn, "Warning.....", JOptionPane.WARNING_MESSAGE );
              btnSave.setEnabled(false); mSave.setEnabled(false); mSaveAs.setEnabled(false);
         class SaveAs
              public SaveAs()
                   JFrame frameSaveAs = new JFrame();
                   frameSaveAs.setLocation(150,150);
                   FileDialog saveFileAs = new FileDialog(frameSaveAs, " Save As ", 1);
                   saveFileAs.show();
                   String fileName = saveFileAs.getDirectory() + saveFileAs.getFile();
                   if(fileName.length() == 8)
                        return;
                   else
                        Notepad.frame.setTitle(saveFileAs.getFile());
                   try
                        FileOutputStream writeFile = new FileOutputStream(fileName);
                        System.out.flush();
                        String input = Notepad.txtArea.getText();
                        for (int n = 0; n < input.length(); n++ )
                             writeFile.write(input.charAt(n) );
                        writeFile.close();
                   catch (Exception e)
                        Object warn = "Unable to save file.........";
                        JOptionPane.showMessageDialog(new JFrame(), warn, "Warning.....", JOptionPane.WARNING_MESSAGE );
    here is the code for clock
    import java.awt.Graphics;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.text.DateFormat;
    //<Applet code=ClockDemo5 Height=500 Width=600>
    //</Applet>
    //Clock with beep & buttons tried to enter alam settings into the applet itself
    //instead of using dialog but still unsucessful
    public class ClockDemo5 extends Applet implements ActionListener,Runnable {
         private Thread clock=null;
         Graphics g,g1;
         Image i1;
         int flag =0,fl=0;
         int beep=0;
         AudioClip clockbeep;
         String months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
         String msg="";
         Button setalarm, stopalarm, help ,ok,cancel;
         Label hrlabel,minlabel;
         TextField hrtxt,mintxt;
         public void init(){
              try{
                   clockbeep=getAudioClip(getDocumentBase(),"clockbell.au");
                   showStatus("Created by : Yogesh Raje");
                   setalarm=new Button("Set Alarm");
                   stopalarm=new Button("Stop Alarm");
                   help=new Button("Help");
                   hrlabel=new Label("Enter Hour : ");
                   hrtxt=new TextField(2);
                   minlabel=new Label("Enter Minutes : ");
                   mintxt=new TextField(2);
                   ok=new Button("Ok");               
                   cancel=new Button("Cancel");
                   add(setalarm);
                   add(stopalarm);
                   add(help);
                   add(hrlabel);
                   add(hrtxt);
                   add(minlabel);
                   add(mintxt);
                   add(ok);
                   add(cancel);
                   hrlabel.setVisible(false);
                   hrtxt.setVisible(false);
                   minlabel.setVisible(false);
                   mintxt.setVisible(false);
                   ok.setVisible(false);
                   cancel.setVisible(false);
                   setalarm.addActionListener(this);
                   stopalarm.addActionListener(this);
                   help.addActionListener(this);
                   ok.addActionListener(this);
                   cancel.addActionListener(this);
              catch(Exception e){
                   showStatus("Unable To Load Audio Clip");
         public void start(){
              showStatus("Created by : Yogesh Raje");
              if(clock==null){
                   clock=new Thread(this,"clock");
                   clock.start();
         public void actionPerformed(ActionEvent ae){
              String str=ae.getActionCommand     ();
              flag=1;
    //          if(str.equals("Set Alarm")){
              if(ae.getSource()==setalarm){
                   hrlabel.setVisible(true);
                   hrtxt.setVisible(true);
                   minlabel.setVisible(true);
                   mintxt.setVisible(true);
                   ok.setVisible(true);
                   cancel.setVisible(true);
              else if(str.equals("Stop Alarm")){
              else if(str.equals("Help"))
                   msg="About help";
              mypaint();
         public void run(){
              showStatus("Created by : Yogesh Raje");
              Thread myclock=Thread.currentThread();
              g=getGraphics();
              i1=createImage(500,600);
              g1=i1.getGraphics();
              g1.setFont(new Font("Dialog",Font.BOLD,48));
              while(myclock==clock){
                   try{
                        beep--;
                        mypaint();
                        Thread.sleep(1000);
                   }catch(InterruptedException e){}
         public void mypaint(){
              Dimension d=getSize();
              Calendar cal=Calendar.getInstance();
              Date time=cal.getTime();
              DateFormat dateformat=DateFormat.getTimeInstance();
              int s=90+cal.get(Calendar.SECOND)*-6;
              int m=90+cal.get(Calendar.MINUTE)*-6;
              int h=90+cal.get(Calendar.HOUR)*-30+(int)(cal.get(Calendar.MINUTE)*-0.5);     
              //if(cal.get(Calendar.SECOND)==0 && cal.get(Calendar.MINUTE)==0){
                   fl=1;
                   beep=cal.get(Calendar.MINUTE);
              if(fl==1)
                   clockbeep.play();
              if(beep==1)
                   fl=0;
              //if(cal.get(Calendar.HOUR)==Integer.parseInt(cd.h1) && cal.get(Calendar.MINUTE)==Integer.parseInt(cd.m1))
                   //clockbeep.loop();
              showStatus("Created by : Yogesh Raje");          
              g1.setColor(Color.white);
              g1.fillRect(0,0,100,150);
              g1.setColor(Color.black);
              g1.drawString(beep+"",25,125);
              //g1.drawString(s1+"",25,35);
              g1.setColor(Color.black);
              g1.fillOval(d.width/2-200,d.height/2-200,400,400);
              g1.setColor(Color.orange);
              g1.fillOval(d.width/2-175,d.height/2-175,350,350);
              g1.setColor(Color.white);
              g1.setFont(new Font("Dialog",Font.BOLD,25));
              g1.fillRect(0,450,600,30);
              g1.setColor(Color.red);
              g1.drawString(dateformat.format(time),100,475);
              g1.drawString(""+months[cal.get(Calendar.MONTH)]+" "+cal.get(Calendar.DATE)+" "+cal.get(Calendar.YEAR),350,475);
              g1.setColor(Color.white);
              g1.setFont(new Font("Dialog",Font.BOLD,50));
              g1.drawString("12",267,125);
              g1.drawString("6",282,412);
              g1.drawString("9",132,270);
              g1.drawString("3",437,270);
              g1.setColor(Color.black);
              g1.fillArc(d.width/2-75,d.height/2-75,150,150,h,2);
              g1.setColor(Color.gray);
              g1.fillArc(d.width/2-100,d.height/2-100,200,200,m,2);
              g1.setColor(Color.green);
              g1.fillArc(d.width/2-125,d.height/2-125,250,250,s,1);
              g1.fillOval(d.width/2-5,d.height/2-5,10,10);
              g1.setFont(new Font("Dialog",Font.BOLD,18));
              g1.setColor(Color.black);
              if(flag==1){
                   flag=0;
                   g1.setColor(Color.white);
                   g1.fillRect(0,0,225,50);
              g1.drawString(msg,5,40);
              g.drawImage(i1,0,0,null);
         public void stop(){
              clock=null;
    please help me! i beg for ur help!!!!!!!!

    application->applet
    get rid of static variables. if nothing else helps put all your static variables in a class that does nothing but holding them and initialize only one such class and add a reference to it in every of your classes.
    whatever you have done in the main method do it now in the constructor of that class.
    from your applet (or if you have none make one that does nothing else) construct an instance of that class
    applet->application
    put all you have drawn directly on the applet ontpo some sort of window.
    change the init method to a constructor.
    make a class with a main method that constructs such an exapplet

  • Regarding Applet Security

    Hello,
    I want to know if an Applet is Signed and policy file is maintained, Can
    1. Applet Viewer can still be used to access the file from the end user system?
    2. Access Control lists can be used to read a file?
    Thank you

    Try to modify the java.policy file which is located under the folder ...\jre\lib\security\, and make sure:
    grant codeBase "file:${java.home}/lib/ext/*" {
         permission java.security.AllPermission;
    Hope this help.

  • How do I save information from my applets?

    I have an inventory applet. But I want to save the information I input to the applet. Everytime I close it, I lose all those information. How do I do this? Do I do it with streams? If so, could you show me the ropes or send me a website. Thanks to anyone who can help! =)

    well well well dekassegui!!! what u said could save my ass from my manager.. coz he will kick me out if i didn't do that for him,.. i've been through alot of documentation regarding applets and their resterictions.. i know that for an applet to access the memory (File IO or Database access) it needs a permission file on the same folder as the applet... some documentation says that an applet should be signed before doing so!! and plz don't ask me what a signed applet means : ) well if that would help plz give me the guide for that.. thanks in advance
    Khalid

  • Applets in IE anddatabase connection

    hello all,
    I have two problems regarding applets
    1).I have an applet that is trying to make a connection to a different host.But while it does it gives me a security exception saying access denied.
    2).I have compiled my applet as
    javac -target 1.1 JVoucher1.java
    because i am using J2re1.4.0 .It compiles but when i try to run from the browser by disabling J2re1.4.0 in the browser properties it fails to come up.It comes otherwsie if i enable j2re1.4.0
    Suggest and help.
    regards,
    nikhil

    bumpert
    Thanks.Are you sure that i have to get it signed. There is no other solution you mean.
    About he second problem i got it working using the Object tag that looks like this:
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    HEIGHT="610" WIDTH="975" ALIGN="bottom" ARCHIVE="classes12.jar,classes111.jar" codebase="http://apps1.cbfamilies.org/test/j2re-1_4_0-win.exe#Version=1,4,0,0" >
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
    <PARAM NAME="code" VALUE="JVoucher1.class">
    <param name=workerTextField value= nikhil >
    No JDK 1.4 support for APPLET!!
    </OBJECT>
    I am installing Java plugin to be compatibale with 1.2 .This works fine.
    I thought we can also do through javac -target 1.1 JVoucher1.java which
    when compiled alllows the applet class to be compatible with the 1.1 of Microsoft VMin IE.
    Any suggection from the forum or Sun guys.
    nikhil

  • Applet on mac hangs

    Hi all,
    I'm currently working on applet that is running well in a windows environment (using different versions of the Sun JRE). Now, I'd like to have this applet also being available to mac users (safari browser - sun jre for mac).
    The applet is relatively simple : it is running in the background and pops up when called by the javascript when the application needs the password from the user (it's pki app, signed for filesystem access).
    The applet loads correctly but it seems to have a problem to display the AWT dialog box and more precisely it seems to freeze when the showDialog method that afterwards creates the awt frame and draws it, is called.
    To get rid of it, the browser must be closed.
    It looks like a deadlock or a thread priority problem, as if the awt thread can't go on...
    Did anyone experience the problem once ?
    For your info, when my applet starts, I'm starting another thread (say t2) to make my methods callable from the javascript. It's a signed applet, and Sun recently changed the policy regarding applet-javascript communication (briefly stated, threads in applet initiated by a javascript call, don't have the privileges to perform sensitive operations (among others, file acces...) anymore. So my main thread actually delegates its work to the second thread I created (t2) (more info somewhere on this forum)
    Could that be linked to the problem ? It's working correctly on windows, however.
    Thanks for your help.
    AD

    The JRE for Mac OS X is available from Apple via the program Software Updates. Trying running the program and obtaining the most recent version available which should be 1.4.2. What version are you using now..
    And if you could post some code, whatever snippet from the original is relevant to the problem, that would help others to help you. Someone could try to reproduce the effect on their own machine that way. Just a thought.

  • Signed applets and restrictions ?

    Hello,
    I've a question regarding applets security : in fact I've tried to sign myself a Jar file containing all required classes for an application (using the jarsigner tool from Sun). However I'm still getting security problems even of it was digitally signed ans don't understand exactly the causes : Could somebody explain me them ? I understood that I had to sign the Jar files using an official authority like Verisign to get all permissions, is it true ? Would it mean that we can't get these permissions without paying any submissions ?
    TU a lot...
    PA
    http://wwww.doffoel.com

    I understood that I had to sign the Jar files using an official authority like Verisign to get all permissions, is it true ?
    Its not compulsory to go to verisign for signing your applet. You can also create your own certificates with Java's keytool. Its 200% free of cost. However, if you are inclined to build a commercial application, where you don't know the clients, who download the applet, get certs from verisign , Thales et al.
    Would it mean that we can't get these permissions without paying any submissions ?
    No. Not at all. You can always make a descent application without going to the standard certificates and without paying $$$.
    Post your quetions in http://forum.java.sun.com/forum.jsp?forum=63 for expert answers.
    Have a look at this famous thread for signing applets.
    http://forum.java.sun.com/thread.jsp?forum=63&thread=132769
    good wishes,
    Rajesh

  • Applet is dead?

    Dear All,
    I have one question regarding applet. Whether applet is alive or dead. The need for the question is while browing in the site 4 months back everybody loading the applet. But past two months the applet is missing in all of those sites including "java.sun.com". So i belive applet is dead. Another point here is java webstart also
    overwrites the applet in many places. Please clarify me regarding this.
    Thanks and Regards
    V.S.Saravanan

    I solved my problem. Supreme thanks to baftos -- Re: InvocationTargetException when running signed applet locally with 7u45

  • Display Font for Attachment

    Dear all,
    Is it possible to set the font to non-proportional spacing on attachment entering so that we can have WYSIWYG on printing? If possible, then how?
    Thanks,
    EC

    I am having the same problem setting fonts in a Java App as described earlier in this thread regarding applets. All of my fonts show up when I call GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(), however when I set to these fonts using setFont() the font size and style are correct but not the face. The faces all appear to be either Arial, Courier New, or Times New Roman. The context is very simple, I am doing this in a Dialog, and setting the font on a Label. It is definitely not a repaint issue.
    Perhaps the author claiming to have setFont() working in an App could post a code snippet...

  • SVG in ADF

    Hi folks,
    I want to embed some interactive SVG graphics in my ADF application.
    So when a user clicks on an object in SVG I have somehow to propagate the event to the ADF/JSF domain to navigate the view objects.
    I read some papers from Frank regarding Applet/ADF interaction, tried to do something similar with SVG-didn't work yet.
    Anyone has experience with SVG?
    Thanks,
    Kresimir

    As an alternative you might consider using xsql:
    XSQL SVG Example questions
    SVG Example Source - XSQL
    in cooperation with ADF.
    NA
    http://nickaiva.blogspot.com

Maybe you are looking for

  • Windows Folder icon instead of Officejet 6500a Plus E710n icon in Devices and Printers

    Can anyone help me to get the OfficeJet 6500a Plus e710n printer icon to display properly in Devices and Printers? I recently reinstalled Windows 8.1.  However, when I installed my printer, instead of the printer icon appearing in Devices and Printer

  • When changing computers...?

    Next week I will be getting a new computer which also will involve moving from Vista to Win7 Pro.   I'm wondering if there are any suggestions as to which files I can transfer over (besides the site files) to make this easier. I'm not sure if I can c

  • Does Nokia Asha 310 support reading ebooks?

    Hello everyone, Pls let me know if it is possible to read ebooks in Asha 310? If yes, what formats does this support like .txt or .pdf or .epub etc If not, then is it possible to install any app (third party is also fine) which will help support read

  • Encoding issues

    Hi, I have XML document with elements like: <?xml version="1.0" encoding="UTF-8" ?> <LastName>Böhme</LastName> <LastName>Hühnermann</LastName> When I put the file into oracle and query it, it gives me back something like: LAST_NAME Böhme Hühnermann

  • Cannot Find Loops?

    I recently bought a Firewire Hard Drive and went to move some of the loop files from my Mac HD to the firewire, and now every time I try to access the files within Soundtrack Pro, the font is red and I cannot reconnect the files. How do I move loop f