Run applet as application

Hi To All,
I'm converting a Applet into Application.
All the things are runing well but when my Applet gets to try the access getDocumentBase() method
its giving a nullPointerException
My all code is written below please help me to find out the problem
import java.awt.Frame;
import java.awt.event.*;
import java.awt.Dimension;
import java.applet.Applet;
// Applet to Application Frame window
public class AppletFrame extends Frame implements java.awt.event.WindowListener
public static void startApplet(String className, String title,String args[])
{ Dimension appletSize;
try
// create an instance of your applet class
myApplet = (Applet) Class.forName(className).newInstance();
catch (ClassNotFoundException e)
{ System.out.println("AppletFrame " + e);
return;
catch (InstantiationException e)
System.out.println("AppletFrame " + e);
return;
} catch (IllegalAccessException e)
System.out.println("AppletFrame " + e);
return;
} // initialize the applet myApplet.init();
myApplet.start();
AppletFrame f = new AppletFrame(title);
f.add("Center", myApplet);
f.addWindowListener(f);
appletSize = myApplet.getSize();
f.pack();
f.setSize(appletSize);
f.show();
public AppletFrame(String name)
{ super(name);
} public void windowClosing(java.awt.event.WindowEvent ev)
{ myApplet.stop();
myApplet.destroy();
java.lang.System.exit(0);
} public void windowClosed(java.awt.event.WindowEvent ev) {}
public void windowActivated(java.awt.event.WindowEvent ev) {}
public void windowDeactivated(java.awt.event.WindowEvent ev) {}
public void windowOpened(java.awt.event.WindowEvent ev) {}
public void windowIconified(java.awt.event.WindowEvent ev) {}
public void windowDeiconified(java.awt.event.WindowEvent ev) {}
private static Applet myApplet;
public static void main(String args[]){
startApplet("appletImageBook.appletImage.Standalone2","XApplets",args);
====================================================
And Standalone2.java is
public class Standalone2 extends Applet {
Image img ;
public void init()
{ add(new Button("Standalone Applet Button"));
img = getImage(getDocumentBase(),"images/office1.jpg");
public void paint(Graphics g) {
g.drawImage(img,0,0,null);
=====================================================
And while runing AppletFrame.java it is giving Error below
===============================
Exception in thread "main" java.lang.NullPointerException at java.applet.Applet.getDocumentBase(Applet.java:125)
at appletImageBook.appletImage.Standalone2.init(Standalone2.java:20) at appletImageBook.appletImage.AppletFrame.startApplet(AppletFrame.java: 38)
at appletImageBook.appletImage.AppletFrame.main(AppletFrame.java:99)
===============================
Any type of help will be fine for me
Thanks in advance

The only difference between an applet and an application should be the way they are started.
Instead of adding an applet to a frame, open a frame from the applet. Open the same frame from your application.
Or instead of a frame, use a (J)Panel. Add it directly to your applet, or add it to a new frame when you want to run it as an application.
In any case: separate the way the UI is created from the way the application is started.

Similar Messages

  • To convert applet-based application?

    Hi
    There are some tools on market to run an applet-based application on server side. Those tools convert the behavior of applet application to Jsp application. So they run the application on web server and send HTML to web browser.
    One of those tools is WebCream(www.creamtec.com)
    Would appreciate to let me know other tools or any other ways to achive this.
    Thanks in Advance.

    repost

  • How do i run a java application in jdk1.3

    im trying to run a java application in jdk 1.3. I created it in jbuilder and i was trying to use the applet viewer.

    http://java.sun.com/j2se/1.3/docs/tooldocs/win32/appletviewer.html
    Jesper

  • Not able to run Applet after calling JSP with a Servlet

    Dear Java-Community :)
    At first I want to say, that my English isn't the best.. so I hope you'll understand my problem ;)
    I'm running a J2EE-Application, packed in a EAR-File, on my JBoss with following directory-structur:
    /jaw6c/bin
    /jaw6c/build
    /jaw6c/common
    /jaw6c/ejb
    /jaw6c/sql
    /jaw6c/src
    /jaw6c/webapp
    /jaw6c/webapp/build
    /jaw6c/webapp/build/classes
    /jaw6c/webapp/build/classes/com
    /jaw6c/webapp/build/classes/com/jbossatwork
    /jaw6c/webapp/build/classes/com/jbossatwork/ControllerServlet.class<<<<<<<<
    /jaw6c/webapp/build/distribution
    /jaw6c/webapp/build/distribution/webapp.war
    /jaw6c/webapp/build/gensrc
    /jaw6c/webapp/compile-lib
    /jaw6c/webapp/lib
    /jaw6c/webapp/src
    /jaw6c/webapp/src/com
    /jaw6c/webapp/src/com/jbossatwork
    /jaw6c/webapp/src/com/jbossatwork/ControllerServlet.java
    /jaw6c/webapp/web
    /jaw6c/webapp/web/WEB-INF
    /jaw6c/webapp/web/WEB-INF/classes
    /jaw6c/webapp/web/buyCarForm.jsp
    /jaw6c/webapp/web/carForm.jsp
    /jaw6c/webapp/web/carList.jsp
    /jaw6c/webapp/web/copy_darstellungErgebnisse.jsp
    /jaw6c/webapp/web/darstellungErgebnisse.jsp<<<<<<<<<<<<<<
    /jaw6c/webapp/web/default.css
    /jaw6c/webapp/web/diag.jar
    /jaw6c/webapp/web/diagram.class<<<<<<<<<<<<<<<<<<<<<<<<
    /jaw6c/webapp/web/error.jsp
    /jaw6c/webapp/web/index.jsp
    /jaw6c/webapp/web/selectBewertungslaeufeList.jsp
    /jaw6c/webapp/build.xml
    /jaw6c/build.xmlThe applet should be loaded in my "darstellungErgebnisse.jsp"-File.
    Now the strange situation:
    When I access "darstellungErgebnisse.jsp" DIRECTLY by entering a URL like "localhost:8080/jaw/darstellungErgebnisse.jsp" , the applet is loading perfectly !
    But when my server is forwarding me to the JSP-Site with
    RequestDispatcher dispatcher =  getServletContext().getRequestDispatcher(destinationPage);
    dispatcher.forward(request, response);
    . . . . . . . ..I'll get a ""java.lang.ClassFormatError: Incompatible magic value 1008813135 in class file diagram
    " -Error what means (referenced on the articles I've read here), that the diagram.class Is not found !
    I have tried to put the class file in a JAR, in different locations... using the codebase and archive tag but NOTHING solved my problem.
    So my question:
    Why I'm able to access the JSP-File directly and seeing the applet but after forwarding to the JSP-File via the Servlet, I'm not able to see anything.
    Would appreciate your help
    Thank you and best regards
    Edit:
    1) I'm able to download the diag.jar and diagram.class file from different locations
    2)I recognized, that after using the servlet, my url is changing from
    localhost:8080/jaw
    to
    localhost:8080/jaw/controller
    I tried added the class file to the position, where the controller-class file is, but without sucess.
    3)Opening the class-file with a hex-editor shows me, that
    the first bytes are
    "CAFEBABE0000002E02B9070002010007"
    (http://forum.java.sun.com/thread.jspa?threadID=648990&messageID=3820701)
    Message was edited by:
    Khaled01

    Hello everybody,
    I finaly have found the solution (after 16 hours).
    Like I mentioned before, I recognized (maybe a little to late), that my path is changing when I'm using the servlet :
    localhost:8080/jaw
    to
    localhost:8080/jaw/controller
    (made by url-pattern in my web.xml).
    So when my JSP tries to acces the class file, It's looking at:
    localhost:8080/jaw/controller/applet/diagram.class
    but the file is in:
    localhost:8080/jaw/applet/diagram.class
    So the solution is, to but a codebase-tag in my applet-declaration with following delcaration "basedir="../applet"
    I hope I'll help somebody with the same problems. It took me a day to find out, that the solution was two points and a slash..... lol
    Regards to everybody

  • Is it possible to run a java application within a web browser?

    Hello everyone here! I have a question about running a java application within a web browser and I would appreciate it very much if anyone here can give me some answers.
    I have a standalone java application written with AWT. Basically this free application lets users to select spectral lines from a big file based on some criteria and plot those selected lines. Yes, it is a very simple application. Now I want to run this application within a web browser so that users don't need to download the application from the ftp site and thus don't need to install in their machine. Is it possible to run this application within browser? If yes, can we get the same plotting function as we run the application separately and where should I start out?
    Thanks in advance!
    kuilian

    Please see the signed applet discussion group for details of how to avoid the applet security restrictions. You can sign the applet, or use the policy file containing {AllPermission} for testing purposes (though not suitable for widespread deployment).
    Regards
    Matthew

  • HT1338 II need to use Java 6 to run a web application because it isnt compatible with java 7 update 7.  is this possible? need to use Java 6 to run a web application because it isnt compatible with java 7 update 7.  is this possible?

    II need to use Java 6 to run a web application because it isnt compatible with java 7 update 7.  is this possible?

    MadMAC0 posted at https://discussions.apple.com/message/20107182?ac_cid=tw123456#20107182 that:
    Apple has posted (10/22/12) the approved solution for restoring the Java 6 plug-in:
    Java for OS X 2012-006: How to re-enable the Apple-provided Java SE 6 applet plug-in and Web Start functionality.

  • How to run a FXML application on a server?

    I would like to learn how to run a FXML application as applet directly on a server with no download for the client part.
    My question:
    1) Is it possible?
    2) Is there someone so kind to give me some basic steps I have to follow to accomplish this?
    A working example of the whole process would be very appreciated.
    Thanks very much.

    I'm not sure the question really makes sense.
    FXML is a markup language for laying out the user interface in a JavaFX application. So "FXML application" doesn't really make sense; you have JavaFX applications whose layout may or may not be managed by FXML. What you can do with those applications doesn't depend on whether FXML is used. In any event, JavaFX applications are inherently client-side applications; they have a user interface and expect user interaction. It wouldn't make sense to run these on a server.
    So it's not really clear to me what you mean.

  • How to run a .jar application via the web

    I have a java application called up.jar which runs a gui application when run via the command line:
    javaw com.vignette.integrate.runtime.ZipFileRuntime up.jar
    I want to run this in a web browser but am just starting to learn html and java. Can anyone please knock a quick script together that I can use to get this to run!!!?
    Thanks
    Ian

    The short answer is, it doesn't work like that.
    A longer answer: Something that runs as an application doesn't necessarily work as an applet (i.e., in a browser) and making it run as an applet usually can't be done without knowing the details about the code in question.
    However it's possible that the jar already contains code that allows it to be invoked as an applet. Did you check vignette.com to see if they have any documentation on this?

  • Is it possible to run applet without JRE

    hello friends,
    Presently I hava developed chating application. Now I want to download my applet on client side and run ther wether client's computer has JRE or not.
    so is it possible to run applet on computer which doesnt have JRE?
    Thanks in advance

    Not unless you create an executable file and jam the whole JRE into it.

  • Applet or application wont compile now?

    I recently got a new computer at work. After I set everything up, including jre & sdk 1.4.1, and path file ifno on my windows xp box (same setup as the other machine), my same applications are now throwing errors?
    It's as if for some reason my old setup was more lax on catching compile time errors.
    Whats even weirder, is the old applets and applications compiled on my old machine still run fine and if I try to compile the old applets and applications without resaving them, I get no error, its just after I resave them, even if I only add a blank line to the file.
    any suggestions
    Jason

    any suggestionsYes, tell us what the errors are exactly! And you should probably show relevant parts of the code too.

  • Running Applet without Browser

    Hello All,
    I've developed a test applet which contains a button.
    When i click the button a Frame opens and does whatever i try to do,
    Thus,to Run my applet i type the URL in the Browser and click the button to open the Frame.
    My Problem is the Frame is destroyed as soon as the browser is closed!
    I need the frame to be browser independent.
    Could anybody suggest me how this would be possible?
    Thank you!

    Applets are intended to be run in browsers.
    There is a program included with the JDK that can run an applet - look for the appletviewer program. There are insructions on its use in the Java tools documentation.
    It sounds like you should be running a Java application, not an applet.

  • 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

  • Running Adobe AIR applications without having Adobe AIR installed

    Is running Adobe AIR applications without having Adobe AIR
    installed possible?
    Why wouldn`t it be?
    And if not, when will it be possible?
    Thank you.

    There's no technical way this could be possible. It's like a
    .swf playing without the Flash Player installed, or a Java applet
    without the Java Virtual Machine. Or even like a Windows
    application running without Windows. :)
    There are, however, 3rd party wrappers out there to turn AIR
    apps into native OS apps (basically it wraps the AIR Runtime inside
    a native OS executable, like .exe). One that I can name off the top
    of my head is the Shu wrapper. This is like the old school Flash
    projectors, like Zinc and mProjector. The user doesn't have to
    install anything to run native executables.
    I would be surprised if Adobe has any plans to make an
    executable wrapper for AIR, but I don't know anything. I would like
    to see .air files be able to run in the AIR Runtime without having
    to actually install the .air package, though.

  • Error running Applet

    I am getting an error
    Can't find resource for bundles sun.applet.resources.MsgAppletViewer,
    key appletpanel.badattribute.exception
    while running applet.
    How can I solve it?

    Some thing is amok here.
    Your AppModule is beginning to be created.
    Some property values are being determined -
    I think your property file is missing -
    property values are defaulted. (0/null/...)
    Your applet seems to be crashing with the
    null property values recieved.
    I think you are missing one of your deployment files.
    Are you sure you can 'Test' the application module in it's own project (Right click on <Name>Module in your project and select Test.
    I hope this helps,
    -John
    null

  • Error while running a J2EE application on Oracle10gAS

    Hi,
    I am receiving an error when trying to run a J2EE application on Oracle10gAS. The application runs successfully on Oracle9iAS, but throws the following exception on 10g application server:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <SOAP-ENV:Body>
    - <SOAP-ENV:Fault>
    <faultcode>SOAP-ENV:Server.Exception:</faultcode>
    <faultstring>com.evermind.server.rmi.OrionRemoteException: Error in createInstance(): null; nested exception is: java.lang.NoClassDefFoundError</faultstring>
    <faultactor>/STAR-TicketBroker-context-root/TicketBrokerWS</faultactor>
    </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Does anyone have any idea why I would be receiving this
    error? We are using Session EJBs in our J2EE application. Are there any changes needed in the code in order to migrate a J2EE application from 9i to 10g ???
    Please help.
    Thanks,
    -Prashant

    Hi Somil,
    I've just had this same error message, and it was because I had a bogus character in my JSP sources.  I'd cut-and-pasted the text from a Word document, and it included the "registered trademark" sign (an R in a circle) as a single character.  This worked in my test environment, but not in my production environment (where presumably the default encoding is different).  I replaced the character with the equivalent HTML entity &amp;reg; (ie. the five characters & r e g ; ) and it all worked.
    Have a look through the offending JSPs and see whether you have any characters that might be incompatible with your default encoding (anything that isn't plain old 7-bit ASCII is potentially a problem).  Change them to HTML entities and you should be fine.
    Hope this helps,
    Richie

Maybe you are looking for