CreateImage Applet/JFrame

Hi, i got this problem with the createImage method, what i am trying to do is to create several smaller images from a larger image, the program works perfectly in an Applet but if i change this line:
public class ImgBDemo extends Applet {To:
public class ImgBDemo extends JFrame {I get a NullPointerException at this line:
upImage = imgBDemo.createImage(w, h);
g = upImage.getGraphics(); //HERE I GET THE NullPointerException
g.drawImage(bigimage, -col*w, -row*h, imgBDemo);Could anyone please tell me what the problem is and if there is any way to fix this problem.
Thx.
Here is the code, it's not stand-alone so it won't work if you try to run it.
import java.applet.Applet;
import java.awt.Color;
import java.awt.Event;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ImgBDemo extends Applet {
     boolean showImageLoadingStatus = true;
     public Image getImageNow(String imagePath) {
          MediaTracker tracker = new MediaTracker(this);
          Image image = null;
          if (showImageLoadingStatus) {
               System.out.println("Loading image: " + imagePath);
          image = Toolkit.getDefaultToolkit().getImage(imagePath);
          tracker.addImage(image, 0);
          try {
               image = Toolkit.getDefaultToolkit().getImage(imagePath);
               tracker.addImage(image, 0);
               tracker.waitForID(0);
          catch (InterruptedException e) {
          if (tracker.isErrorID(0)) {
               System.out.println("ERROR loading image: " + imagePath);
               System.out.println("ERROR loading image: " + imagePath);
          if (showImageLoadingStatus) {
               System.out.println("");
          return image;
     public void init() {
          ControlPanel cp = new ControlPanel(this);
          add(cp);
     public static void main(String args[]) {
          JFrame f = new JFrame("Kali");
          ImgBDemo imgBDemo = new ImgBDemo();
          imgBDemo.init();
          f.add("Center", imgBDemo);
          f.setSize(300, 300);
          f.setVisible(true);
class ControlPanel extends JPanel {
     ImgBDemo imgBDemo;
     ImageButton[] groupButton = new ImageButton[36];
     ImageButton[] colorButton = new ImageButton[6];
     GridBagLayout gridbag = new GridBagLayout();
      * Create a new control panel object.
     public ControlPanel(ImgBDemo imgBDemo) {
          this.imgBDemo = imgBDemo;
          setBackground(Color.lightGray);
          int buttonRowCount = 7;
          int buttonsPerRow = 6;
          Image bigimage = imgBDemo.getImageNow("buttons.png");
          Image upImage, downImage;
          int w = 32, h = 32;
          Graphics g;
          int row = 0;
          int col = 0;
          GridBagConstraints c;
          setLayout(gridbag);
          //   Create the group buttons; each button gets put into
          //   its own little panel (the bPanel array) together with
          //   its label.  It's in this loop where we chop up the big
          //   image into individual ones for the buttons.
          ImageButtonGroup groupButtons = new ImageButtonGroup();
          JPanel[] bPanel = new JPanel[groupButton.length];
          c = new GridBagConstraints();
          c.gridwidth = GridBagConstraints.REMAINDER;
          for (int i=0; i<36; ++i) {
               upImage = imgBDemo.createImage(w, h);
                * Here is where i get the null pointer exception, the previous createImage(w,h)
                * only seems to return null when using JFrame, in an Applet it works fine.
               g = upImage.getGraphics();
               g.drawImage(bigimage, -col*w, -row*h, imgBDemo);
               downImage = imgBDemo.createImage(w, h);
               g = downImage.getGraphics();
               g.drawImage(bigimage, -col*w, -(row+buttonRowCount)*h, imgBDemo);
               groupButton[i] = new ImageButton(upImage, downImage, groupButtons);
               bPanel[i] = new JPanel();
               bPanel.setLayout(gridbag);
               gridbag.setConstraints(groupButton[i], c);
               bPanel[i].add(groupButton[i]);
               ++col;
               if (col >= buttonsPerRow) {
                    col = 0;
                    ++row;
          // Create the color buttons
          ImageButtonGroup colorButtons = new ImageButtonGroup();
          for (int i=0; i<6; ++i) {
               upImage = imgBDemo.createImage(w, h);
               g = upImage.getGraphics();
               g.drawImage(bigimage, -col*w, -row*h, imgBDemo);
               downImage = imgBDemo.createImage(w, h);
               g = downImage.getGraphics();
               g.drawImage(bigimage, -col*w, -(row+buttonRowCount)*h, imgBDemo);
               colorButton[i] = new ImageButton(upImage, downImage, colorButtons);
               ++col;
               if (col >= buttonsPerRow) {
                    col = 0;
                    ++row;
          // Create the color panel and layout the color
          // buttons in it.
          JPanel colorPanel = new JPanel();
               colorPanel.setLayout(new GridLayout(1,6));
               for (int i=0; i<6; ++i) {
                    colorPanel.add(colorButton[i]);
          // color panel
          gridbag.setConstraints(colorPanel, c);
          add(colorPanel);
     * Given a color button, return its index.
     public int findColor(ImageButton button) {
          return -1;
     * Handling method for button actions.
     public boolean action(Event e, Object arg) {
          if (e.target instanceof ImageButton) {
               ImageButton button = (ImageButton)e.target;
               int i = findColor(button);
               if (i>=0) {
//                    currentColor = i;
               } else {
                    System.out.println("unknown image button pressed");
          return true;

So the trick is simply to display the containers before i create the image, got it.
Thx.

Similar Messages

  • Applet, JFrame: Display icons in toolbar

    Hello,
    I've a class called Designer which extends Applet. In the init method two JFrames are opened: DesignerFrame and DrawPanel. In the DesignerFrame I have a toolbar with icons. When I run the Applet in Eclipse (on my local computer) he shows the icons. When I put the application on my webserver, and I open it with my browser on my local computer, he doesn't show the icons. The icons are in a folder called pwdImages.
    Does anyone know how to solve this problem?
    Thanks a lot!!!
    Koen.

    Hello,
    Thanks for the answers. Here's some code of the DesignerFrame class:
    // Handles color menu items
         class ColorAction extends AbstractAction {
              public ColorAction(String name, Color color) {
                   super(name);
                   this.color = color;
                   String iconFileName = "pwdImages/" + name + ".gif";
                   if (new File(iconFileName).exists())
                        putValue(SMALL_ICON, new ImageIcon(iconFileName));
              public ColorAction(String name, Color color, String tooltip) {
                   this(name, color);
                   if (tooltip != null) // If there is a tooltip
                        putValue(SHORT_DESCRIPTION, tooltip); // ...squirrel it away
              public void actionPerformed(ActionEvent e) {
                   elementColor = color;
                   statusBar.setColorPane(color);
              private Color color;
    addMenuItem(
                   colorMenu,
                   redAction = new ColorAction("Red", Color.RED, "Draw in red"));
    // Element color actions
         private ColorAction redAction, yellowAction, greenAction, blueAction;
    ...

  • Javaswing and applet

    can i used java swing in an Applet???
    please Send Me some Code!!!!!if Possible

    I have just told you it was possible - no need to be so uptight !
    HTML code :
    <HTML>
    <HEAD>
       <TITLE>Applet HTML Page</TITLE>
    </HEAD>
    <BODY>
    <P>
    <APPLET code="myApplet.class" width=350 height=200></APPLET>
    </P>
    </BODY>
    </HTML>Java code :
    import java.applet.*;
    import javax.swing.*;
    public class myApplet extends Applet{
        JFrame jf=new JFrame();
        public void init(){
            jf.pack();
            jf.setVisible(true);
        public void destroy(){
            jf.dispose();
    }And a good day to you too !
    BadLands

  • Help with getting Images to show in a Rock, Paper, Scissors game

    Hi
    I am working on this Rock, paper, scissors java game and the program works, but I can not figure out how to get the images to load onto the program. So my question is how do I get the images to load up with the program? I am using JCreator for this project. I have created the Basic Java Application project, and then added in the 3 .java files that I need to run the program, but I just can not figure out how or where I need to upload the files. The game works without the images, but I would really like them to show up.
    This is the .java file that calls up the images:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class pss extends JPanel implements ActionListener, ItemListener
    private final Color clrBackground = new Color(163,243,255);
    private final Color clrForeground = new Color(0,0,0);
    private JComboBox cboxWeapon;
    private JTextField txtCPUWeapon, txtWins, txtLoses, txtDraws;
    private JLabel lblPlayerWeapon, lblCPUWeapon, lblWins, lblLoses, lblDraws, lblStatus, lblPlayerWeaponIcon, lblCPUWeaponIcon;
    private JButton cmdPlay, cmdReset;
    private ImageIcon[] imgWeapon;
    private JPanel panRoot, panPlayerArea, panPlayerWeapon, panCPUArea, panCPUWeapon, panStatusArea, panGo, panCounters, panWins, panLoses, panDraws;
    private pssEngine engine = new pssEngine();
    private objCreateAppletImage createImage = new objCreateAppletImage();
    private boolean errorWithImages = false;
    public static void main(String[] args) //With applications, you have to specify a main method (not with applets)
    JFrame.setDefaultLookAndFeelDecorated(true); //Make it look nice
    JFrame frame = new JFrame("Paper Stone Scissors"); //Title
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false); //Stops the user resizing the window
    JComponent paneMain = new pss();
    paneMain.setOpaque(true);
    paneMain.setPreferredSize(new Dimension(420,350));
    frame.setContentPane(paneMain);
    frame.pack();
    frame.setVisible(true);
    public pss ()
    cboxWeapon = new JComboBox(engine.getWeapon());
    cboxWeapon.addItemListener(this);
    txtCPUWeapon = new JTextField(engine.getStrCPUWeapon(), 5);
    txtWins = new JTextField("0", 5);
    txtLoses = new JTextField("0", 5);
    txtDraws = new JTextField("0", 5);
    txtCPUWeapon.setEditable(false);
    txtWins.setEditable(false);
    txtLoses.setEditable(false);
    txtDraws.setEditable(false);
    lblPlayerWeapon = new JLabel("Choose your weapon", JLabel.CENTER);
    lblCPUWeapon = new JLabel("The CPU's weapon", JLabel.CENTER);
    lblWins = new JLabel("Amount of wins:", JLabel.RIGHT);
    lblLoses = new JLabel("Amount of loses:", JLabel.RIGHT);
    lblDraws = new JLabel("Amount of Drawss:", JLabel.RIGHT);
    lblStatus = new JLabel("", JLabel.CENTER);
    lblPlayerWeaponIcon = new JLabel("", JLabel.CENTER);
    lblCPUWeaponIcon = new JLabel("", JLabel.CENTER);
    lblPlayerWeaponIcon.setPreferredSize(new Dimension(150,150));
    lblCPUWeaponIcon.setPreferredSize(new Dimension(150,150));
    cmdPlay = new JButton("Go!");
    cmdReset = new JButton("Restart");
    cmdPlay.addActionListener(this);
    cmdReset.addActionListener(this);
    try
    imgWeapon = new ImageIcon[3];
    for (int i = 0; i < 3; i++)
    imgWeapon[i] = createImage.getImageIcon(this, ".src/images/" + engine.getWeapon(i) + ".gif", "Icon for " + engine.getWeapon(i), 13000);
    lblPlayerWeaponIcon.setIcon(imgWeapon[0]);
    lblCPUWeaponIcon.setIcon(imgWeapon[0]);
    catch (Exception ex) //The game works without the images, so carry on
    errorWithImages = true;
    setLayout(new BorderLayout());
    panRoot = new JPanel(new BorderLayout());
    panPlayerArea = new JPanel(new BorderLayout());
    panPlayerWeapon = new JPanel(new BorderLayout());
    panCPUArea = new JPanel(new BorderLayout());
    panCPUWeapon = new JPanel(new BorderLayout());
    panStatusArea = new JPanel(new BorderLayout());
    panGo = new JPanel();
    panCounters = new JPanel(new GridLayout(3,1,2,2));
    panWins = new JPanel();
    panLoses = new JPanel();
    panDraws = new JPanel();
    add(panRoot, BorderLayout.CENTER);
    panRoot.add(panPlayerArea, BorderLayout.WEST);
    panPlayerArea.add(panPlayerWeapon, BorderLayout.NORTH);
    panPlayerWeapon.add(lblPlayerWeapon, BorderLayout.NORTH);
    panPlayerWeapon.add(cboxWeapon, BorderLayout.SOUTH);
    panPlayerArea.add(lblPlayerWeaponIcon, BorderLayout.SOUTH);
    panRoot.add(panCPUArea, BorderLayout.EAST);
    panCPUArea.add(panCPUWeapon, BorderLayout.NORTH);
    panCPUWeapon.add(lblCPUWeapon, BorderLayout.NORTH);
    panCPUWeapon.add(txtCPUWeapon, BorderLayout.SOUTH);
    panCPUArea.add(lblCPUWeaponIcon, BorderLayout.SOUTH);
    panRoot.add(panStatusArea, BorderLayout.SOUTH);
    panStatusArea.add(panGo, BorderLayout.NORTH);
    panGo.add(cmdPlay);
    panGo.add(cmdReset);
    panGo.add(lblStatus);
    panStatusArea.add(panCounters, BorderLayout.SOUTH);
    panCounters.add(panWins);
    panWins.add(lblWins);
    panWins.add(txtWins);
    panCounters.add(panLoses);
    panLoses.add(lblLoses);
    panLoses.add(txtLoses);
    panCounters.add(panDraws);
    panDraws.add(lblDraws);
    panDraws.add(txtDraws);
    panRoot.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    setBackground(clrBackground);
    panRoot.setBackground(clrBackground);
    panPlayerArea.setBackground(clrBackground);
    panPlayerWeapon.setBackground(clrBackground);
    panCPUArea.setBackground(clrBackground);
    panCPUWeapon.setBackground(clrBackground);
    panStatusArea.setBackground(clrBackground);
    panGo.setBackground(clrBackground);
    panCounters.setBackground(clrBackground);
    panWins.setBackground(clrBackground);
    panLoses.setBackground(clrBackground);
    panDraws.setBackground(clrBackground);
    lblPlayerWeapon.setForeground(clrForeground);
    lblCPUWeapon.setForeground(clrForeground);
    lblWins.setForeground(clrForeground);
    lblLoses.setForeground(clrForeground);
    lblDraws.setForeground(clrForeground);
    txtWins.setForeground(clrForeground);
    txtLoses.setForeground(clrForeground);
    txtDraws.setForeground(clrForeground);
    txtCPUWeapon.setForeground(clrForeground);
    public void reset ()
    cboxWeapon.setSelectedIndex(0);
    lblStatus.setText("");
    engine.reset();
    public void actionPerformed (ActionEvent e)
    if (e.getSource() == cmdReset)
    reset();
    else
    lblStatus.setText(engine.play(cboxWeapon.getSelectedIndex()));
    txtCPUWeapon.setText(engine.getStrCPUWeapon());
    txtWins.setText(Integer.toString(engine.getWins()));
    txtLoses.setText(Integer.toString(engine.getLoses()));
    txtDraws.setText(Integer.toString(engine.getDraws()));
    if (!errorWithImages)
    lblCPUWeaponIcon.setIcon(imgWeapon[engine.getCPUWeapon()]);
    public void itemStateChanged (ItemEvent e)
    if (!errorWithImages)
    lblPlayerWeaponIcon.setIcon(imgWeapon[cboxWeapon.getSelectedIndex()]);
    }Here is the other .java file that calls on the Images:
    import java.awt.*;
    import java.io.*;
    import javax.swing.ImageIcon;
    public class objCreateAppletImage
    public void objCreateAppletImage ()
    //If an error occurs (or is thrown by me) it will be thrown to the next level up, and either caught or thrown
    public ImageIcon getImageIcon (Object parentClass, String path, String description, int fileSize) throws Exception
    int count = 0;
    BufferedInputStream imgStream = new BufferedInputStream(parentClass.getClass().getResourceAsStream(path));
    byte buff[] = new byte[fileSize];
    if (imgStream == null) //If doesn't exist
    throw new Exception("File not Found");
    try
    count = imgStream.read(buff);
    imgStream.close(); //Closes the stream
    catch (IOException ex)
    throw new Exception("Corrupt file");
    return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buff), description); //Creates the image from the byte array
    }Could someone please help me? I really have no idea and I would like this to work.
    Thank you
    Frank

    Oh, thank you. I will not do that in the future.
    I am not entirely sure how I would use the getImage method in an Applet. I would prefer to just use the code that I have currently, unless the addition of making the program an Applet only adds a small amount of code. But then even still, I am not entirely sure what I would write in the .class file to make the images load. And then I would not really know how to properly incorporate the pss.java file and the .class file together so they read off of each other.

  • 1.4.2 vs 1.4.1_02 speed comparison

    Houston, we have a problem....
    I have a swing applet(JFrame) that updates 1800 JLabel boxes(yes they are tiny, no text) with a color.
    1.4.1_02 is about 8 times faster than 1.4.2 to initially update the screen after it displays
    by changing all the JLabel colors based on the data sent via socket connection from the server.
    I recompiled with 1.4.2 jsdk and loaded 1.4.2 jre on my win NT4.0sp6/Netscape 4.76 pc,
    updated my applet code for 1.4.2 plugins.
    1.4.1_01 takes about 2 seconds, 1.4.2 takes 10 seconds.
    If this is an indication of whats to come in 1.5, i'll be stuck with 1.4.1_02 forever.
    However, other applets that display a 2 megabyte JTable seem to be the same speed.
    No errors in java console.
    Does anybody see speed problems with JLabels or swing components in general?

    Perhaps you should create a test case and submit a bug against 1.4.2 indicating that it's a performance regression.

  • Snapshot of a colored table

    Hi,
    Does anyone know of any design pattern or of any standard class that can return a snapshot of a JTable?
    What I want to do is to create a small picture of a large table and then add the zooming and panning functionality to it, so that we can easily traverse the large table.The table has cells of different colors.
    So is getting a smaller snapshot directly possible or do I have to actually create a 2D graphics picture of the table.
    Thanks
    Connie

    Hi Dr Ness,
    as you suggested I had a look at that thread and tried that code, but it returns a blank image.The code I have used is as follows.I have created a class called dynamic table which is supposed to display the image of the component passed in its constructor in a new frame.
    public class DynamicTable {
    public DynamicTable(Component cmp) {
    BufferedImage bi=createImage(cmp);
    JFrame jf1 = new JFrame();
    jf1.getContentPane().paint(bi.getGraphics());
    jf1.setVisible(true);
    jf1.pack();
    jf1.setSize(300,300);
    public static BufferedImage createImage(Component cmp) {
    Rectangle d = cmp.getBounds();
    BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = bi.createGraphics();
    //temporary container
    JFrame jf = new JFrame();
    jf.getContentPane().add(cmp);
    jf.pack();
    SwingUtilities.paintComponent(g2d,cmp,jf.getContentPane(), 100,100,d.width,d.height);
    return bi;
    any suggestions will be of great help.
    thanks
    connie

  • LiveConnect crashes browser????  External exception thrown.

    Hey,
    Im using an applet that sometimes calls liveconnect, specifically when the applet JFrame is closed, it has the browser navigate to another page.
    This part works great. Then maybe 5 minutes later, and sporadically, IE will crash and put a file on my desktop (winXP).
    Please let me know if you have any ideas, here's some code and the error file from the desktop:
    try {           
    //gets the applet reference
    JSObject win = JSObject.getWindow(
    (Applet)MainMenu.getCurrentMenu().getParent());
    //calls a javascript function, this part works great
    Object answer = win.eval("appletGlue('" + theFunction
    + "', " + questionID + ",'" + param3 + "');");
    //even checks the javascript return value...
    if (answer.toString().equals(ResourceFactory.JAVASCRIPT_SUCCESS)) {
    //done, this works fine too
    return;
    //response = "Success";
    } else {
    response = "ERROR: could not " + errorMessage + " , "
    + answer.toString();
    } catch (Exception e) {
    response = "ERROR: could not properly access the \n" +
    "browser to " + errorMessage + " , exception thrown";
    e.printStackTrace();
    JSObject is the liveconnect class
    com.ar.testbank are my classes
    =======================================================================
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : unknown exception code occurred at PC=0x77E6D756
    Function=RaiseException+0x50
    Library=F:\WINDOWS\system32\kernel32.dll
    Current Java thread:
         at sun.plugin.javascript.ocx.JSObject.nativeInvoke(Native Method)
         at sun.plugin.javascript.ocx.JSObject.invoke(JSObject.java:93)
         - locked <10F00B48> (a sun.plugin.javascript.ocx.JSObject)
         at sun.plugin.javascript.ocx.JSObject.getMember(JSObject.java:201)
         at sun.plugin.javascript.ocx.JSObject.eval(JSObject.java:183)
         at com.ar.testbank.ui.resources.RemoteResourceFactory.doJavascriptCall(Unknown Source)
         at com.ar.testbank.ui.resources.RemoteResourceFactory.doMainMenu(Unknown Source)
         at com.ar.testbank.ui.gui.StatusBottomPanel$5.actionPerformed(Unknown Source)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:258)
         at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:227)
         at java.awt.Component.processMouseEvent(Component.java:5021)
         at java.awt.Component.processEvent(Component.java:4818)
         at java.awt.Container.processEvent(Container.java:1525)
         at java.awt.Component.dispatchEventImpl(Component.java:3526)
         at java.awt.Container.dispatchEventImpl(Container.java:1582)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3359)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3074)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
         at java.awt.Container.dispatchEventImpl(Container.java:1568)
         at java.awt.Window.dispatchEventImpl(Window.java:1581)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
    Dynamic libraries:
    0x00400000 - 0x00419000      F:\Program Files\Internet Explorer\IEXPLORE.EXE
    0x77F50000 - 0x77FF9000      F:\WINDOWS\System32\ntdll.dll
    0x77E60000 - 0x77F45000      F:\WINDOWS\system32\kernel32.dll
    0x77C10000 - 0x77C63000      F:\WINDOWS\system32\msvcrt.dll
    0x77D40000 - 0x77DCD000      F:\WINDOWS\system32\USER32.dll
    0x77C70000 - 0x77CB0000      F:\WINDOWS\system32\GDI32.dll
    0x77DD0000 - 0x77E5B000      F:\WINDOWS\system32\ADVAPI32.dll
    0x77CC0000 - 0x77D35000      F:\WINDOWS\system32\RPCRT4.dll
    0x772D0000 - 0x77333000      F:\WINDOWS\system32\SHLWAPI.dll
    0x769C0000 - 0x76B09000      F:\WINDOWS\System32\SHDOCVW.dll
    0x71950000 - 0x71A34000      F:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.0.0_x-ww_1382d70a\comctl32.dll
    0x773D0000 - 0x77BC4000      F:\WINDOWS\system32\SHELL32.dll
    0x77340000 - 0x773CB000      F:\WINDOWS\system32\comctl32.dll
    0x771B0000 - 0x772CA000      F:\WINDOWS\system32\ole32.dll
    0x5AD70000 - 0x5ADA4000      F:\WINDOWS\system32\uxtheme.dll
    0x74720000 - 0x7476B000      F:\WINDOWS\System32\MSCTF.dll
    0x75F80000 - 0x7607C000      F:\WINDOWS\System32\BROWSEUI.dll
    0x72430000 - 0x72442000      F:\WINDOWS\System32\browselc.dll
    0x75F40000 - 0x75F5D000      F:\WINDOWS\system32\appHelp.dll
    0x76FD0000 - 0x77048000      F:\WINDOWS\System32\CLBCATQ.DLL
    0x77120000 - 0x771AB000      F:\WINDOWS\system32\OLEAUT32.dll
    0x77050000 - 0x77115000      F:\WINDOWS\System32\COMRes.dll
    0x77C00000 - 0x77C07000      F:\WINDOWS\system32\VERSION.dll
    0x76200000 - 0x76297000      F:\WINDOWS\system32\WININET.dll
    0x762C0000 - 0x7634A000      F:\WINDOWS\system32\CRYPT32.dll
    0x762A0000 - 0x762AF000      F:\WINDOWS\system32\MSASN1.dll
    0x76F90000 - 0x76FA0000      F:\WINDOWS\System32\Secur32.dll
    0x76620000 - 0x7666E000      F:\WINDOWS\System32\cscui.dll
    0x76600000 - 0x7661B000      F:\WINDOWS\System32\CSCDLL.dll
    0x76670000 - 0x76754000      F:\WINDOWS\System32\SETUPAPI.dll
    0x760F0000 - 0x76168000      F:\WINDOWS\system32\urlmon.dll
    0x76170000 - 0x761F8000      F:\WINDOWS\System32\shdoclc.dll
    0x74770000 - 0x747FF000      F:\WINDOWS\System32\mlang.dll
    0x71AD0000 - 0x71AD8000      F:\WINDOWS\System32\wsock32.dll
    0x71AB0000 - 0x71AC5000      F:\WINDOWS\System32\WS2_32.dll
    0x71AA0000 - 0x71AA8000      F:\WINDOWS\System32\WS2HELP.dll
    0x71A50000 - 0x71A8B000      F:\WINDOWS\system32\mswsock.dll
    0x71A90000 - 0x71A98000      F:\WINDOWS\System32\wshtcpip.dll
    0x76EE0000 - 0x76F17000      F:\WINDOWS\System32\RASAPI32.DLL
    0x76E90000 - 0x76EA1000      F:\WINDOWS\System32\rasman.dll
    0x71C20000 - 0x71C6F000      F:\WINDOWS\System32\NETAPI32.dll
    0x76EB0000 - 0x76EDA000      F:\WINDOWS\System32\TAPI32.dll
    0x76E80000 - 0x76E8D000      F:\WINDOWS\System32\rtutils.dll
    0x76B40000 - 0x76B6C000      F:\WINDOWS\System32\WINMM.dll
    0x5CD70000 - 0x5CD77000      F:\WINDOWS\System32\serwvdrv.dll
    0x5B0A0000 - 0x5B0A7000      F:\WINDOWS\System32\umdmxfrm.dll
    0x722B0000 - 0x722B5000      F:\WINDOWS\System32\sensapi.dll
    0x75A70000 - 0x75B13000      F:\WINDOWS\system32\USERENV.dll
    0x75E90000 - 0x75F31000      F:\WINDOWS\System32\SXS.DLL
    0x76F20000 - 0x76F45000      F:\WINDOWS\System32\DNSAPI.dll
    0x76FB0000 - 0x76FB7000      F:\WINDOWS\System32\winrnr.dll
    0x76F60000 - 0x76F8C000      F:\WINDOWS\system32\WLDAP32.dll
    0x605D0000 - 0x605DF000      F:\WINDOWS\System32\mslbui.dll
    0x76FC0000 - 0x76FC5000      F:\WINDOWS\System32\rasadhlp.dll
    0x76D60000 - 0x76D75000      F:\WINDOWS\System32\iphlpapi.dll
    0x76DE0000 - 0x76E06000      F:\WINDOWS\System32\netman.dll
    0x76D40000 - 0x76D56000      F:\WINDOWS\System32\MPRAPI.dll
    0x76E40000 - 0x76E6F000      F:\WINDOWS\System32\ACTIVEDS.dll
    0x76E10000 - 0x76E34000      F:\WINDOWS\System32\adsldpc.dll
    0x76B20000 - 0x76B35000      F:\WINDOWS\System32\ATL.DLL
    0x71BF0000 - 0x71C01000      F:\WINDOWS\System32\SAMLIB.dll
    0x76DA0000 - 0x76DD0000      F:\WINDOWS\System32\WZCSvc.DLL
    0x76D30000 - 0x76D34000      F:\WINDOWS\System32\WMI.dll
    0x76D80000 - 0x76D9A000      F:\WINDOWS\System32\DHCPCSVC.DLL
    0x76F50000 - 0x76F58000      F:\WINDOWS\System32\WTSAPI32.dll
    0x76360000 - 0x7636F000      F:\WINDOWS\System32\WINSTA.dll
    0x74810000 - 0x74ABD000      F:\WINDOWS\System32\mshtml.dll
    0x513E0000 - 0x5140D000      F:\Program Files\Common Files\Microsoft Shared\VS7Debug\pdm.dll
    0x51300000 - 0x51328000      F:\Program Files\Common Files\Microsoft Shared\VS7Debug\msdbg2.dll
    0x746F0000 - 0x74719000      F:\WINDOWS\System32\msimtf.dll
    0x5C2C0000 - 0x5C303000      F:\WINDOWS\ime\sptip.dll
    0x76400000 - 0x765FB000      F:\WINDOWS\System32\msi.dll
    0x10000000 - 0x1005B000      F:\Program Files\Common Files\Microsoft Shared\Ink\SKCHUI.DLL
    0x32520000 - 0x32532000      F:\Program Files\Microsoft Office\Office10\msohev.dll
    0x75C50000 - 0x75CE1000      F:\WINDOWS\System32\jscript.dll
    0x746C0000 - 0x746E7000      F:\WINDOWS\System32\MSLS31.DLL
    0x74CB0000 - 0x74D1F000      F:\WINDOWS\System32\mshtmled.dll
    0x72D20000 - 0x72D29000      F:\WINDOWS\System32\wdmaud.drv
    0x72D10000 - 0x72D18000      F:\WINDOWS\System32\msacm32.drv
    0x77BE0000 - 0x77BF4000      F:\WINDOWS\System32\MSACM32.dll
    0x77BD0000 - 0x77BD7000      F:\WINDOWS\System32\midimap.dll
    0x73300000 - 0x73375000      F:\WINDOWS\System32\vbscript.dll
    0x58510000 - 0x58575000      F:\WINDOWS\System32\macromed\flash\swflash.ocx
    0x763B0000 - 0x763F5000      F:\WINDOWS\system32\comdlg32.dll
    0x6D430000 - 0x6D439000      F:\WINDOWS\System32\ddrawex.dll
    0x73760000 - 0x737A5000      F:\WINDOWS\System32\DDRAW.dll
    0x73BC0000 - 0x73BC6000      F:\WINDOWS\System32\DCIMAN32.dll
    0x71D40000 - 0x71D5B000      F:\WINDOWS\System32\actxprxy.dll
    0x6CC60000 - 0x6CC6B000      F:\WINDOWS\System32\dispex.dll
    0x72B20000 - 0x72B38000      F:\WINDOWS\System32\plugin.ocx
    0x72E00000 - 0x72F14000      F:\WINDOWS\System32\msxml3.dll
    0x5FE20000 - 0x5FE9E000      F:\WINDOWS\System32\mstime.dll
    0x66880000 - 0x6688A000      F:\WINDOWS\System32\imgutil.dll
    0x66E50000 - 0x66E8B000      F:\WINDOWS\System32\iepeers.dll
    0x73000000 - 0x73023000      F:\WINDOWS\System32\WINSPOOL.DRV
    0x05B50000 - 0x05B65000      F:\Program Files\Java\j2re1.4.0_01\bin\npjpi140_01.dll
    0x05B70000 - 0x05B8C000      F:\Program Files\Java\j2re1.4.0_01\bin\beans.ocx
    0x05B90000 - 0x05BA5000      F:\Program Files\Java\j2re1.4.0_01\bin\jpishare.dll
    0x07B00000 - 0x07C15000      F:\PROGRA~1\Java\J2RE14~1.0_0\bin\client\jvm.dll
    0x6D1D0000 - 0x6D1D7000      F:\PROGRA~1\Java\J2RE14~1.0_0\bin\hpi.dll
    0x6D300000 - 0x6D30D000      F:\PROGRA~1\Java\J2RE14~1.0_0\bin\verify.dll
    0x6D210000 - 0x6D228000      F:\PROGRA~1\Java\J2RE14~1.0_0\bin\java.dll
    0x6D320000 - 0x6D32D000      F:\PROGRA~1\Java\J2RE14~1.0_0\bin\zip.dll
    0x6D000000 - 0x6D0F6000      F:\Program Files\Java\j2re1.4.0_01\bin\awt.dll
    0x76390000 - 0x763AA000      F:\WINDOWS\System32\IMM32.dll
    0x6D180000 - 0x6D1D0000      F:\Program Files\Java\j2re1.4.0_01\bin\fontmanager.dll
    0x6D2D0000 - 0x6D2DD000      F:\Program Files\Java\j2re1.4.0_01\bin\net.dll
    0x6D130000 - 0x6D152000      F:\Program Files\Java\j2re1.4.0_01\bin\dcpr.dll
    0x05BB0000 - 0x05BBA000      F:\Program Files\Java\j2re1.4.0_01\bin\packager.dll
    0x5FF50000 - 0x5FF61000      F:\WINDOWS\System32\msratelc.dll
    0x0EE30000 - 0x0EE63000      F:\WINDOWS\System32\spool\DRIVERS\W32X86\3\UNIDRVUI.DLL
    0x07450000 - 0x0747B000      F:\WINDOWS\System32\spool\DRIVERS\W32X86\3\UNIDRV.DLL
    0x71B20000 - 0x71B31000      F:\WINDOWS\system32\MPR.dll
    0x75F60000 - 0x75F66000      F:\WINDOWS\System32\drprov.dll
    0x71C10000 - 0x71C1D000      F:\WINDOWS\System32\ntlanman.dll
    0x71CD0000 - 0x71CE6000      F:\WINDOWS\System32\NETUI0.dll
    0x71C90000 - 0x71CCC000      F:\WINDOWS\System32\NETUI1.dll
    0x71C80000 - 0x71C86000      F:\WINDOWS\System32\NETRAP.dll
    0x75F70000 - 0x75F79000      F:\WINDOWS\System32\davclnt.dll
    0x75970000 - 0x75A61000      F:\WINDOWS\System32\MSGINA.dll
    0x1F7B0000 - 0x1F7E1000      F:\WINDOWS\System32\ODBC32.dll
    0x1F850000 - 0x1F866000      F:\WINDOWS\System32\odbcint.dll
    0x76C30000 - 0x76C5B000      F:\WINDOWS\System32\wintrust.dll
    0x76C90000 - 0x76CB2000      F:\WINDOWS\system32\IMAGEHLP.dll
    0x767F0000 - 0x76814000      F:\WINDOWS\System32\schannel.dll
    0x0FFD0000 - 0x0FFF2000      F:\WINDOWS\System32\rsaenh.dll
    0x0FFA0000 - 0x0FFC1000      F:\WINDOWS\System32\dssenh.dll
    0x73D50000 - 0x73D60000      F:\WINDOWS\System32\cryptnet.dll
    0x75150000 - 0x75163000      F:\WINDOWS\System32\Cabinet.dll
    0x76C00000 - 0x76C2D000      F:\WINDOWS\System32\credui.dll
    0x5E0C0000 - 0x5E0CC000      F:\WINDOWS\System32\pstorec.dll
    0x76990000 - 0x769B4000      F:\WINDOWS\System32\ntshrui.dll
    0x61580000 - 0x615B0000      F:\WINDOWS\System32\rmoc3260.dll
    0x78000000 - 0x78048000      F:\WINDOWS\System32\PNCRT.dll
    0x5FF20000 - 0x5FF43000      F:\WINDOWS\System32\MSRATING.DLL
    0x60850000 - 0x6088D000      F:\WINDOWS\System32\msieftp.dll
    0x6BDD0000 - 0x6BE03000      F:\WINDOWS\System32\dxtrans.dll
    0x732E0000 - 0x732E5000      F:\WINDOWS\System32\RICHED32.DLL
    0x74E30000 - 0x74E9B000      F:\WINDOWS\System32\RICHED20.dll
    0x6D510000 - 0x6D58C000      F:\WINDOWS\system32\DBGHELP.dll
    0x76BF0000 - 0x76BFB000      F:\WINDOWS\System32\PSAPI.DLL
    Local Time = Tue Jul 30 03:00:10 2002
    Elapsed Time = 16075
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.4.0_01-b03 mixed mode)

    im getting similar:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : unknown exception code occurred at PC=0x77E6D756
    Function=RaiseException+0x50
    Library=C:\WINDOWS\system32\kernel32.dll
    Current Java thread:
         at sun.plugin.javascript.ocx.JSObject.nativeInvoke(Native Method)
         at sun.plugin.javascript.ocx.JSObject.invoke(Unknown Source)
         - locked <072CC118> (a sun.plugin.javascript.ocx.JSObject)
         at sun.plugin.javascript.ocx.JSObject.getMember(Unknown Source)
         at sun.plugin.javascript.ocx.JSObject.eval(Unknown Source)
         at ServerConnectionTimer.jsCall(ServerConnectionTimer.java:61)
         at ServerConnectionTimer.run(ServerConnectionTimer.java:46)
         at java.lang.Thread.run(Unknown Source)
    Dynamic libraries:
    0x00400000 - 0x00419000      C:\Program Files\Internet Explorer\IEXPLORE.EXE
    0x77F50000 - 0x77FF9000      C:\WINDOWS\System32\ntdll.dll
    0x77E60000 - 0x77F45000      C:\WINDOWS\system32\kernel32.dll
    0x77C10000 - 0x77C63000      C:\WINDOWS\system32\msvcrt.dll
    0x77D40000 - 0x77DCD000      C:\WINDOWS\system32\USER32.dll
    0x77C70000 - 0x77CB0000      C:\WINDOWS\system32\GDI32.dll
    0x77DD0000 - 0x77E5B000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77CC0000 - 0x77D35000      C:\WINDOWS\system32\RPCRT4.dll
    0x772D0000 - 0x77333000      C:\WINDOWS\system32\SHLWAPI.dll
    0x71700000 - 0x71848000      C:\WINDOWS\System32\SHDOCVW.dll
    0x629C0000 - 0x629C8000      C:\WINDOWS\System32\LPK.DLL
    0x72FA0000 - 0x72FFA000      C:\WINDOWS\System32\USP10.dll
    0x71950000 - 0x71A34000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.0.0_x-ww_1382d70a\comctl32.dll
    0x773D0000 - 0x77BC4000      C:\WINDOWS\system32\SHELL32.dll
    0x77340000 - 0x773CB000      C:\WINDOWS\system32\comctl32.dll
    0x771B0000 - 0x772CA000      C:\WINDOWS\system32\ole32.dll
    0x5AD70000 - 0x5ADA4000      C:\WINDOWS\system32\uxtheme.dll
    0x10000000 - 0x10006000      C:\DOCUME~1\MONTED~1\LOCALS~1\Temp\IadHide3.dll
    0x75F80000 - 0x7607C000      C:\WINDOWS\System32\BROWSEUI.dll
    0x72430000 - 0x72442000      C:\WINDOWS\System32\browselc.dll
    0x75F40000 - 0x75F5D000      C:\WINDOWS\system32\appHelp.dll
    0x76FD0000 - 0x77048000      C:\WINDOWS\System32\CLBCATQ.DLL
    0x77120000 - 0x771AB000      C:\WINDOWS\system32\OLEAUT32.dll
    0x77050000 - 0x77115000      C:\WINDOWS\System32\COMRes.dll
    0x77C00000 - 0x77C07000      C:\WINDOWS\system32\VERSION.dll
    0x63000000 - 0x63094000      C:\WINDOWS\system32\WININET.dll
    0x762C0000 - 0x7634A000      C:\WINDOWS\system32\CRYPT32.dll
    0x762A0000 - 0x762AF000      C:\WINDOWS\system32\MSASN1.dll
    0x76F90000 - 0x76FA0000      C:\WINDOWS\System32\Secur32.dll
    0x76620000 - 0x7666E000      C:\WINDOWS\System32\cscui.dll
    0x76600000 - 0x7661B000      C:\WINDOWS\System32\CSCDLL.dll
    0x76670000 - 0x76754000      C:\WINDOWS\System32\SETUPAPI.dll
    0x1A400000 - 0x1A479000      C:\WINDOWS\system32\urlmon.dll
    0x00E50000 - 0x00ED8000      C:\WINDOWS\System32\shdoclc.dll
    0x74770000 - 0x747FF000      C:\WINDOWS\System32\mlang.dll
    0x71AD0000 - 0x71AD8000      C:\WINDOWS\System32\wsock32.dll
    0x71AB0000 - 0x71AC5000      C:\WINDOWS\System32\WS2_32.dll
    0x71AA0000 - 0x71AA8000      C:\WINDOWS\System32\WS2HELP.dll
    0x71A50000 - 0x71A8B000      C:\WINDOWS\system32\mswsock.dll
    0x71A90000 - 0x71A98000      C:\WINDOWS\System32\wshtcpip.dll
    0x00DE0000 - 0x00E19000      C:\WINDOWS\System32\RASAPI32.DLL
    0x76E90000 - 0x76EA1000      C:\WINDOWS\System32\rasman.dll
    0x71C20000 - 0x71C6F000      C:\WINDOWS\System32\NETAPI32.dll
    0x76EB0000 - 0x76EDA000      C:\WINDOWS\System32\TAPI32.dll
    0x76E80000 - 0x76E8D000      C:\WINDOWS\System32\rtutils.dll
    0x76B40000 - 0x76B6C000      C:\WINDOWS\System32\WINMM.dll
    0x76400000 - 0x765FB000      C:\WINDOWS\System32\msi.dll
    0x75A70000 - 0x75B13000      C:\WINDOWS\system32\USERENV.dll
    0x75E90000 - 0x75F31000      C:\WINDOWS\System32\SXS.DLL
    0x0FFD0000 - 0x0FFF2000      C:\WINDOWS\System32\rsaenh.dll
    0x76F20000 - 0x76F45000      C:\WINDOWS\System32\DNSAPI.dll
    0x76FB0000 - 0x76FB7000      C:\WINDOWS\System32\winrnr.dll
    0x76F60000 - 0x76F8C000      C:\WINDOWS\system32\WLDAP32.dll
    0x722B0000 - 0x722B5000      C:\WINDOWS\System32\sensapi.dll
    0x76FC0000 - 0x76FC5000      C:\WINDOWS\System32\rasadhlp.dll
    0x63580000 - 0x63825000      C:\WINDOWS\System32\mshtml.dll
    0x746F0000 - 0x74719000      C:\WINDOWS\System32\msimtf.dll
    0x60000000 - 0x6004C000      C:\WINDOWS\System32\MSCTF.dll
    0x76390000 - 0x763AA000      C:\WINDOWS\System32\IMM32.DLL
    0x75C50000 - 0x75CE1000      C:\WINDOWS\System32\jscript.dll
    0x66E50000 - 0x66E8B000      C:\WINDOWS\System32\iepeers.dll
    0x73000000 - 0x73023000      C:\WINDOWS\System32\WINSPOOL.DRV
    0x746C0000 - 0x746E7000      C:\WINDOWS\System32\MSLS31.DLL
    0x74CB0000 - 0x74D1F000      C:\WINDOWS\System32\mshtmled.dll
    0x72D20000 - 0x72D29000      C:\WINDOWS\System32\wdmaud.drv
    0x72D10000 - 0x72D18000      C:\WINDOWS\System32\msacm32.drv
    0x77BE0000 - 0x77BF4000      C:\WINDOWS\System32\MSACM32.dll
    0x77BD0000 - 0x77BD7000      C:\WINDOWS\System32\midimap.dll
    0x71D40000 - 0x71D5B000      C:\WINDOWS\System32\ACTXPRXY.DLL
    0x66880000 - 0x6688A000      C:\WINDOWS\System32\imgutil.dll
    0x6B600000 - 0x6B671000      C:\WINDOWS\System32\vbscript.dll
    0x58510000 - 0x58575000      C:\WINDOWS\System32\macromed\flash\swflash.ocx
    0x763B0000 - 0x763F5000      C:\WINDOWS\system32\comdlg32.dll
    0x6D430000 - 0x6D439000      C:\WINDOWS\System32\ddrawex.dll
    0x73760000 - 0x737A5000      C:\WINDOWS\System32\DDRAW.dll
    0x73BC0000 - 0x73BC6000      C:\WINDOWS\System32\DCIMAN32.dll
    0x01E90000 - 0x01EA5000      C:\Program Files\Java\j2re1.4.0\bin\npjpi140.dll
    0x033E0000 - 0x033FC000      C:\Program Files\Java\j2re1.4.0\bin\beans.ocx
    0x036D0000 - 0x036E5000      C:\Program Files\Java\j2re1.4.0\bin\jpishare.dll
    0x03CD0000 - 0x03DE2000      C:\PROGRA~1\Java\J2RE14~1.0\bin\client\jvm.dll
    0x6D1D0000 - 0x6D1D7000      C:\PROGRA~1\Java\J2RE14~1.0\bin\hpi.dll
    0x6D300000 - 0x6D30D000      C:\PROGRA~1\Java\J2RE14~1.0\bin\verify.dll
    0x6D210000 - 0x6D228000      C:\PROGRA~1\Java\J2RE14~1.0\bin\java.dll
    0x6D320000 - 0x6D32D000      C:\PROGRA~1\Java\J2RE14~1.0\bin\zip.dll
    0x6D000000 - 0x6D0F6000      C:\Program Files\Java\j2re1.4.0\bin\awt.dll
    0x6D180000 - 0x6D1D0000      C:\Program Files\Java\j2re1.4.0\bin\fontmanager.dll
    0x69500000 - 0x6981E000      C:\WINDOWS\System32\nvoglnt.dll
    0x6D2D0000 - 0x6D2DD000      C:\Program Files\Java\j2re1.4.0\bin\net.dll
    0x6D130000 - 0x6D152000      C:\Program Files\Java\j2re1.4.0\bin\dcpr.dll
    0x03F60000 - 0x03F6A000      C:\Program Files\Java\j2re1.4.0\bin\packager.dll
    0x6D280000 - 0x6D29E000      C:\Program Files\Java\j2re1.4.0\bin\jpeg.dll
    0x732E0000 - 0x732E5000      C:\WINDOWS\System32\RICHED32.DLL
    0x74E30000 - 0x74E9B000      C:\WINDOWS\System32\RICHED20.dll
    0x6D2A0000 - 0x6D2C1000      C:\Program Files\Java\j2re1.4.0\bin\jsound.dll
    0x76C90000 - 0x76CB2000      C:\WINDOWS\system32\imagehlp.dll
    0x6D510000 - 0x6D58C000      C:\WINDOWS\system32\DBGHELP.dll
    0x76BF0000 - 0x76BFB000      C:\WINDOWS\System32\PSAPI.DLL
    Local Time = Thu Aug 29 22:41:50 2002
    Elapsed Time = 727
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.4.0-b92 mixed mode)

  • How do I convert this Applet to launch from a JFrame instead??

       A simple program where the user can sketch curves and shapes in a
       variety of colors on a variety of background colors.  The user selects
       a drawing color form a pop-up menu at the top of the
       applet.  If the user clicks "Set Background", the background
       color is set to the current drawing color and the drawing
       area is filled with that color.  If the user clicks "Clear",
       the drawing area is just filled with the current background color.
       The user selects the shape to draw from another pop-up menu at the
       top of the applet.  The user can draw free-hand curves, straight
       lines, and one of six different types of shapes.
       The user's drawing is saved in an off-screen image, which is
       used to refresh the screen when repainting.  The picture is
       lost if the applet changes size, however.
       This file defines two classes, SimplePaint3,class, and
       class, SimplePaint3$Display.class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SimplePaint3 extends JApplet {
            // The main applet class simply sets up the applet.  Most of the
            // work is done in the Display class.
       JComboBox colorChoice, figureChoice;  // Pop-up menus, defined as instance
                                             // variables so that the Display
                                             // class can see them.
       public void init() {
          setBackground(Color.gray);
          getContentPane().setBackground(Color.gray);
          Display canvas = new Display();  // The drawing area.
          getContentPane().add(canvas,BorderLayout.CENTER);
          JPanel buttonBar = new JPanel();       // A panel to hold the buttons.
          buttonBar.setBackground(Color.gray);
          getContentPane().add(buttonBar, BorderLayout.SOUTH);
          JPanel choiceBar = new JPanel();       // A panel to hole the pop-up menus
          choiceBar.setBackground(Color.gray);
          getContentPane().add(choiceBar, BorderLayout.NORTH);
          JButton fill = new JButton("Set Background");  // The first button.
          fill.addActionListener(canvas);
          buttonBar.add(fill);
          JButton clear = new JButton("Clear");   // The second button.
          clear.addActionListener(canvas);
          buttonBar.add(clear);
          colorChoice = new JComboBox();  // The pop-up menu of colors.
          colorChoice.addItem("Black");
          colorChoice.addItem("Red");
          colorChoice.addItem("Green");
          colorChoice.addItem("Blue");
          colorChoice.addItem("Cyan");
          colorChoice.addItem("Magenta");
          colorChoice.addItem("Yellow");
          colorChoice.addItem("White");
          colorChoice.setBackground(Color.white);
          choiceBar.add(colorChoice);
          figureChoice = new JComboBox();  // The pop-up menu of shapes.
          figureChoice.addItem("Curve");
          figureChoice.addItem("Straight Line");
          figureChoice.addItem("Rectangle");
          figureChoice.addItem("Oval");
          figureChoice.addItem("RoundRect");
          figureChoice.addItem("Filled Rectangle");
          figureChoice.addItem("Filled Oval");
          figureChoice.addItem("Filled RoundRect");
          figureChoice.setBackground(Color.white);
          choiceBar.add(figureChoice);
       }  // end init()
       public Insets getInsets() {
              // Specify how wide a border to leave around the edges of the applet.
          return new Insets(3,3,3,3);
       private class Display extends JPanel
                  implements MouseListener, MouseMotionListener, ActionListener {
               // Nested class Display represents the drawing surface of the
               // applet.  It lets the user use the mouse to draw colored curves
               // and shapes.  The current color is specified by the pop-up menu
               // colorChoice.  The current shape is specified by another pop-up menu,
               // figureChoice.  (These are instance variables in the main class.)
               // The panel also listens for action events from buttons
               // named "Clear" and "Set Background".  The "Clear" button fills
               // the panel with the current background color.  The "Set Background"
               // button sets the background color to the current drawing color and
               // then clears.  These buttons are set up in the main class.
          private final static int
                      BLACK = 0,
                      RED = 1,            // Some constants to make
                      GREEN = 2,          // the code more readable.
                      BLUE = 3,           // These numbers code for
                      CYAN = 4,           // the different drawing colors.
                      MAGENTA = 5,
                      YELLOW = 6,
                      WHITE = 7;
          private final static int
                     CURVE = 0,
                     LINE = 1,
                     RECT = 2,               // Some constants that code
                     OVAL = 3,               // for the different types of
                     ROUNDRECT = 4,          // figure the program can draw.
                     FILLED_RECT = 5,
                     FILLED_OVAL = 6,
                     FILLED_ROUNDRECT = 7;
          /* Some variables used for backing up the contents of the panel. */
          Image OSI;  // The off-screen image (created in checkOSI()).
          int widthOfOSI, heightOfOSI;  // Current width and height of OSI.  These
                                        // are checked against the size of the applet,
                                        // to detect any change in the panel's size.
                                        // If the size has changed, a new OSI is created.
                                        // The picture in the off-screen image is lost
                                        // when that happens.
          /* The following variables are used when the user is sketching a
             curve while dragging a mouse. */
          private int mouseX, mouseY;   // The location of the mouse.
          private int prevX, prevY;     // The previous location of the mouse.
          private int startX, startY;   // The starting position of the mouse.
                                        // (Not used for drawing curves.)
          private boolean dragging;     // This is set to true when the user is drawing.
          private int figure;    // What type of figure is being drawn.  This is
                                 //    specified by the figureChoice menu.
          private Graphics dragGraphics;  // A graphics context for the off-screen image,
                                          // to be used while a drag is in progress.
          private Color dragColor;  // The color that is used for the figure that is
                                    // being drawn.
          Display() {
                 // Constructor.  When this component is first created, it is set to
                 // listen for mouse events and mouse motion events from
                 // itself.  The initial background color is white.
             addMouseListener(this);
             addMouseMotionListener(this);
             setBackground(Color.white);
          private void drawFigure(Graphics g, int shape, int x1, int y1, int x2, int y2) {
                // This method is called to do ALL drawing in this applet!
                // Draws a shape in the graphics context g.
                // The shape paramter tells what kind of shape to draw.  This
                // can be LINE, RECT, OVAL, ROUNTRECT, FILLED_RECT,
                // FILLED_OVAL, or FILLED_ROUNDRECT.  (Note that a CURVE is
                // drawn by drawing multiple LINES, so the shape parameter is
                // never equal to CURVE.)  For a LINE, a line is drawn from
                // the point (x1,y1) to (x2,y2).  For other shapes,  the
                // points (x1,y1) and (x2,y2) give two corners of the shape
                // (or of a rectangle that contains the shape).
             if (shape == LINE) {
                   // For a line, just draw the line between the two points.
                g.drawLine(x1,y1,x2,y2);
                return;
             int x, y;  // Top left corner of rectangle that contains the figure.
             int w, h;  // Width and height of rectangle that contains the figure.
             if (x1 >= x2) {  // x2 is left edge
                x = x2;
                w = x1 - x2;
             else {          // x1 is left edge
                x = x1;
                w = x2 - x1;
             if (y1 >= y2) {  // y2 is top edge
                y = y2;
                h = y1 - y2;
             else {          // y1 is top edge.
                y = y1;
                h = y2 - y1;
             switch (shape) {   // Draw the appropriate figure.
                case RECT:
                   g.drawRect(x, y, w, h);
                   break;
                case OVAL:
                   g.drawOval(x, y, w, h);
                   break;
                case ROUNDRECT:
                   g.drawRoundRect(x, y, w, h, 20, 20);
                   break;
                case FILLED_RECT:
                   g.fillRect(x, y, w, h);
                   break;
                case FILLED_OVAL:
                   g.fillOval(x, y, w, h);
                   break;
                case FILLED_ROUNDRECT:
                   g.fillRoundRect(x, y, w, h, 20, 20);
                   break;
          private void repaintRect(int x1, int y1, int x2, int y2) {
                // Call repaint on a rectangle that contains the points (x1,y1)
                // and (x2,y2).  (Add a 1-pixel border along right and bottom
                // edges to allow for the pen overhang when drawing a line.)
             int x, y;  // top left corner of rectangle that contains the figure
             int w, h;  // width and height of rectangle that contains the figure
             if (x2 >= x1) {  // x1 is left edge
                x = x1;
                w = x2 - x1;
             else {          // x2 is left edge
                x = x2;
                w = x1 - x2;
             if (y2 >= y1) {  // y1 is top edge
                y = y1;
                h = y2 - y1;
             else {          // y2 is top edge.
                y = y2;
                h = y1 - y2;
             repaint(x,y,w+1,h+1);
          private void checkOSI() {
               // This method is responsible for creating the off-screen image.
               // It should be called before using the OSI.  It will make a new OSI if
               // the size of the panel changes.
             if (OSI == null || widthOfOSI != getSize().width || heightOfOSI != getSize().height) {
                    // Create the OSI, or make a new one if panel size has changed.
                OSI = null;  // (If OSI already exists, this frees up the memory.)
                OSI = createImage(getSize().width, getSize().height);
                widthOfOSI = getSize().width;
                heightOfOSI = getSize().height;
                Graphics OSG = OSI.getGraphics();  // Graphics context for drawing to OSI.
                OSG.setColor(getBackground());
                OSG.fillRect(0, 0, widthOfOSI, heightOfOSI);
                OSG.dispose();
          public void paintComponent(Graphics g) {
               // Copy the off-screen image to the screen,
               // after checking to make sure it exists.  Then,
               // if a shape other than CURVE is being drawn,
               // draw it on top of the image from the OSI.
             checkOSI();
             g.drawImage(OSI, 0, 0, this);
             if (dragging && figure != CURVE) {
                g.setColor(dragColor);
                drawFigure(g,figure,startX,startY,mouseX,mouseY);
          public void actionPerformed(ActionEvent evt) {
                  // Respond when the user clicks on a button.  The
                  // command must be either "Clear" or "Set Background".
             String command = evt.getActionCommand();
             checkOSI();
             if (command.equals("Set Background")) {
                    // Set background color before clearing.
                    // Change the selected color so it is different
                    // from the background color.
                setBackground(getCurrentColor());
                if (colorChoice.getSelectedIndex() == BLACK)
                   colorChoice.setSelectedIndex(WHITE);
                else
                   colorChoice.setSelectedIndex(BLACK);
             Graphics g = OSI.getGraphics();
             g.setColor(getBackground());
             g.fillRect(0,0,getSize().width,getSize().height);
             g.dispose();
             repaint();
          private Color getCurrentColor() {
                   // Check the colorChoice menu to find the currently
                   // selected color, and return the appropriate color
                   // object.
             int currentColor = colorChoice.getSelectedIndex();
             switch (currentColor) {
                case BLACK:
                   return Color.black;
                case RED:
                   return Color.red;
                case GREEN:
                   return Color.green;
                case BLUE:
                   return Color.blue;
                case CYAN:
                   return Color.cyan;
                case MAGENTA:
                   return Color.magenta;
                case YELLOW:
                   return Color.yellow;
                default:
                   return Color.white;
          public void mousePressed(MouseEvent evt) {
                  // This is called when the user presses the mouse on the
                  // panel.  This begins a draw operation in which the user
                  // sketches a curve or draws a shape.  (Note that curves
                  // are handled differently from other shapes.  For CURVE,
                  // a new segment of the curve is drawn each time the user
                  // moves the mouse.  For the other shapes, a "rubber band
                  // cursor" is used.  That is, the figure is drawn between
                  // the starting point and the current mouse location.)
             if (dragging == true)  // Ignore mouse presses that occur
                 return;            //    when user is already drawing a curve.
                                    //    (This can happen if the user presses
                                    //    two mouse buttons at the same time.)
             prevX = startX = evt.getX();  // Save mouse coordinates.
             prevY = startY = evt.getY();
             figure = figureChoice.getSelectedIndex();
             dragColor = getCurrentColor();        
             dragGraphics = OSI.getGraphics();
             dragGraphics.setColor(dragColor);
             dragging = true;  // Start drawing.
          } // end mousePressed()
          public void mouseReleased(MouseEvent evt) {
                  // Called whenever the user releases the mouse button.
                  // If the user was drawing a shape, we make the shape
                  // permanent by drawing it to the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              dragging = false;
              mouseX = evt.getX();
              mouseY = evt.getY();
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs
                  drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                  repaintRect(prevX,prevY,mouseX,mouseY);
              else if (figure == LINE) {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX || mouseY != startY) {
                       // Draw the line only if it has non-zero length.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              else {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX && mouseY != startY) {
                       // Draw the shape only if both its height
                       // and width are both non-zero.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              dragGraphics.dispose();
              dragGraphics = null;
          public void mouseDragged(MouseEvent evt) {
                   // Called whenever the user moves the mouse while a mouse button
                   // is down.  If the user is drawing a curve, draw a segment of
                   // the curve on the off-screen image, and repaint the part
                   // of the panel that contains the new line segment.  Otherwise,
                   // just call repaint and let paintComponent() draw the shape on
                   // top of the picture in the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              mouseX = evt.getX();   // x-coordinate of mouse.
              mouseY = evt.getY();   // y=coordinate of mouse.
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs.
                 drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                 repaintRect(prevX,prevY,mouseX,mouseY);
              else {
                    // Repaint two rectangles:  The one that contains the previous
                    // version of the figure, and the one that will contain the
                    // new version.  The first repaint is necessary to restore
                    // the picture from the off-screen image in that rectangle.
                 repaintRect(startX,startY,prevX,prevY);
                 repaintRect(startX,startY,mouseX,mouseY);
              prevX = mouseX;  // Save coords for the next call to mouseDragged or mouseReleased.
              prevY = mouseY;
          } // end mouseDragged.
          public void mouseEntered(MouseEvent evt) { }   // Some empty routines.
          public void mouseExited(MouseEvent evt) { }    //    (Required by the MouseListener
          public void mouseClicked(MouseEvent evt) { }   //    and MouseMotionListener
          public void mouseMoved(MouseEvent evt) { }     //    interfaces).
       } // end nested class Display
    } // end class SimplePaint3

    Im quite the novice, how exactly do I go about doing that. What I did was to put both in diff files but I got errors saying that they cant find colorChoice, figureChoice in the Display class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Simple extends JFrame implements Display{
            // The main applet class simply sets up the applet.  Most of the
            // work is done in the Display class.
       JComboBox colorChoice, figureChoice;  // Pop-up menus, defined as instance
                                             // variables so that the Display
                                             // class can see them.
       public void init() {
          setBackground(Color.gray);
          getContentPane().setBackground(Color.gray);
          Display canvas = new Display();  // The drawing area.
          getContentPane().add(canvas,BorderLayout.CENTER);
          JPanel buttonBar = new JPanel();       // A panel to hold the buttons.
          buttonBar.setBackground(Color.gray);
          getContentPane().add(buttonBar, BorderLayout.SOUTH);
          JPanel choiceBar = new JPanel();       // A panel to hole the pop-up menus
          choiceBar.setBackground(Color.gray);
          getContentPane().add(choiceBar, BorderLayout.NORTH);
          JButton fill = new JButton("Set Background");  // The first button.
          fill.addActionListener(canvas);
          buttonBar.add(fill);
          JButton clear = new JButton("Clear");   // The second button.
          clear.addActionListener(canvas);
          buttonBar.add(clear);
          colorChoice = new JComboBox();  // The pop-up menu of colors.
          colorChoice.addItem("Black");
          colorChoice.addItem("Red");
          colorChoice.addItem("Green");
          colorChoice.addItem("Blue");
          colorChoice.addItem("Cyan");
          colorChoice.addItem("Magenta");
          colorChoice.addItem("Yellow");
          colorChoice.addItem("White");
          colorChoice.setBackground(Color.white);
          choiceBar.add(colorChoice);
          figureChoice = new JComboBox();  // The pop-up menu of shapes.
          figureChoice.addItem("Curve");
          figureChoice.addItem("Straight Line");
          figureChoice.addItem("Rectangle");
          figureChoice.addItem("Oval");
          figureChoice.addItem("RoundRect");
          figureChoice.addItem("Filled Rectangle");
          figureChoice.addItem("Filled Oval");
          figureChoice.addItem("Filled RoundRect");
          figureChoice.setBackground(Color.white);
          choiceBar.add(figureChoice);
       }  // end init()
    } // end class SimplePaint3
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Display extends JPanel
                  implements MouseListener, MouseMotionListener, ActionListener {
               // Nested class Display represents the drawing surface of the
               // applet.  It lets the user use the mouse to draw colored curves
               // and shapes.  The current color is specified by the pop-up menu
               // colorChoice.  The current shape is specified by another pop-up menu,
               // figureChoice.  (These are instance variables in the main class.)
               // The panel also listens for action events from buttons
               // named "Clear" and "Set Background".  The "Clear" button fills
               // the panel with the current background color.  The "Set Background"
               // button sets the background color to the current drawing color and
               // then clears.  These buttons are set up in the main class.
          private final static int
                      BLACK = 0,
                      RED = 1,            // Some constants to make
                      GREEN = 2,          // the code more readable.
                      BLUE = 3,           // These numbers code for
                      CYAN = 4,           // the different drawing colors.
                      MAGENTA = 5,
                      YELLOW = 6,
                      WHITE = 7;
          private final static int
                     CURVE = 0,
                     LINE = 1,
                     RECT = 2,               // Some constants that code
                     OVAL = 3,               // for the different types of
                     ROUNDRECT = 4,          // figure the program can draw.
                     FILLED_RECT = 5,
                     FILLED_OVAL = 6,
                     FILLED_ROUNDRECT = 7;
          /* Some variables used for backing up the contents of the panel. */
          Image OSI;  // The off-screen image (created in checkOSI()).
          int widthOfOSI, heightOfOSI;  // Current width and height of OSI.  These
                                        // are checked against the size of the applet,
                                        // to detect any change in the panel's size.
                                        // If the size has changed, a new OSI is created.
                                        // The picture in the off-screen image is lost
                                        // when that happens.
          /* The following variables are used when the user is sketching a
             curve while dragging a mouse. */
          private int mouseX, mouseY;   // The location of the mouse.
          private int prevX, prevY;     // The previous location of the mouse.
          private int startX, startY;   // The starting position of the mouse.
                                        // (Not used for drawing curves.)
          private boolean dragging;     // This is set to true when the user is drawing.
          private int figure;    // What type of figure is being drawn.  This is
                                 //    specified by the figureChoice menu.
          private Graphics dragGraphics;  // A graphics context for the off-screen image,
                                          // to be used while a drag is in progress.
          private Color dragColor;  // The color that is used for the figure that is
                                    // being drawn.
          Display() {
                 // Constructor.  When this component is first created, it is set to
                 // listen for mouse events and mouse motion events from
                 // itself.  The initial background color is white.
             addMouseListener(this);
             addMouseMotionListener(this);
             setBackground(Color.white);
          private void drawFigure(Graphics g, int shape, int x1, int y1, int x2, int y2) {
                // This method is called to do ALL drawing in this applet!
                // Draws a shape in the graphics context g.
                // The shape paramter tells what kind of shape to draw.  This
                // can be LINE, RECT, OVAL, ROUNTRECT, FILLED_RECT,
                // FILLED_OVAL, or FILLED_ROUNDRECT.  (Note that a CURVE is
                // drawn by drawing multiple LINES, so the shape parameter is
                // never equal to CURVE.)  For a LINE, a line is drawn from
                // the point (x1,y1) to (x2,y2).  For other shapes,  the
                // points (x1,y1) and (x2,y2) give two corners of the shape
                // (or of a rectangle that contains the shape).
             if (shape == LINE) {
                   // For a line, just draw the line between the two points.
                g.drawLine(x1,y1,x2,y2);
                return;
             int x, y;  // Top left corner of rectangle that contains the figure.
             int w, h;  // Width and height of rectangle that contains the figure.
             if (x1 >= x2) {  // x2 is left edge
                x = x2;
                w = x1 - x2;
             else {          // x1 is left edge
                x = x1;
                w = x2 - x1;
             if (y1 >= y2) {  // y2 is top edge
                y = y2;
                h = y1 - y2;
             else {          // y1 is top edge.
                y = y1;
                h = y2 - y1;
             switch (shape) {   // Draw the appropriate figure.
                case RECT:
                   g.drawRect(x, y, w, h);
                   break;
                case OVAL:
                   g.drawOval(x, y, w, h);
                   break;
                case ROUNDRECT:
                   g.drawRoundRect(x, y, w, h, 20, 20);
                   break;
                case FILLED_RECT:
                   g.fillRect(x, y, w, h);
                   break;
                case FILLED_OVAL:
                   g.fillOval(x, y, w, h);
                   break;
                case FILLED_ROUNDRECT:
                   g.fillRoundRect(x, y, w, h, 20, 20);
                   break;
          private void repaintRect(int x1, int y1, int x2, int y2) {
                // Call repaint on a rectangle that contains the points (x1,y1)
                // and (x2,y2).  (Add a 1-pixel border along right and bottom
                // edges to allow for the pen overhang when drawing a line.)
             int x, y;  // top left corner of rectangle that contains the figure
             int w, h;  // width and height of rectangle that contains the figure
             if (x2 >= x1) {  // x1 is left edge
                x = x1;
                w = x2 - x1;
             else {          // x2 is left edge
                x = x2;
                w = x1 - x2;
             if (y2 >= y1) {  // y1 is top edge
                y = y1;
                h = y2 - y1;
             else {          // y2 is top edge.
                y = y2;
                h = y1 - y2;
             repaint(x,y,w+1,h+1);
          private void checkOSI() {
               // This method is responsible for creating the off-screen image.
               // It should be called before using the OSI.  It will make a new OSI if
               // the size of the panel changes.
             if (OSI == null || widthOfOSI != getSize().width || heightOfOSI != getSize().height) {
                    // Create the OSI, or make a new one if panel size has changed.
                OSI = null;  // (If OSI already exists, this frees up the memory.)
                OSI = createImage(getSize().width, getSize().height);
                widthOfOSI = getSize().width;
                heightOfOSI = getSize().height;
                Graphics OSG = OSI.getGraphics();  // Graphics context for drawing to OSI.
                OSG.setColor(getBackground());
                OSG.fillRect(0, 0, widthOfOSI, heightOfOSI);
                OSG.dispose();
          public void paintComponent(Graphics g) {
               // Copy the off-screen image to the screen,
               // after checking to make sure it exists.  Then,
               // if a shape other than CURVE is being drawn,
               // draw it on top of the image from the OSI.
             checkOSI();
             g.drawImage(OSI, 0, 0, this);
             if (dragging && figure != CURVE) {
                g.setColor(dragColor);
                drawFigure(g,figure,startX,startY,mouseX,mouseY);
          public void actionPerformed(ActionEvent evt) {
                  // Respond when the user clicks on a button.  The
                  // command must be either "Clear" or "Set Background".
             String command = evt.getActionCommand();
             checkOSI();
             if (command.equals("Set Background")) {
                    // Set background color before clearing.
                    // Change the selected color so it is different
                    // from the background color.
                setBackground(getCurrentColor());
                if (colorChoice.getSelectedIndex() == BLACK)
                   colorChoice.setSelectedIndex(WHITE);
                else
                   colorChoice.setSelectedIndex(BLACK);
             Graphics g = OSI.getGraphics();
             g.setColor(getBackground());
             g.fillRect(0,0,getSize().width,getSize().height);
             g.dispose();
             repaint();
          private Color getCurrentColor() {
                   // Check the colorChoice menu to find the currently
                   // selected color, and return the appropriate color
                   // object.
             int currentColor = colorChoice.getSelectedIndex();
             switch (currentColor) {
                case BLACK:
                   return Color.black;
                case RED:
                   return Color.red;
                case GREEN:
                   return Color.green;
                case BLUE:
                   return Color.blue;
                case CYAN:
                   return Color.cyan;
                case MAGENTA:
                   return Color.magenta;
                case YELLOW:
                   return Color.yellow;
                default:
                   return Color.white;
          public void mousePressed(MouseEvent evt) {
                  // This is called when the user presses the mouse on the
                  // panel.  This begins a draw operation in which the user
                  // sketches a curve or draws a shape.  (Note that curves
                  // are handled differently from other shapes.  For CURVE,
                  // a new segment of the curve is drawn each time the user
                  // moves the mouse.  For the other shapes, a "rubber band
                  // cursor" is used.  That is, the figure is drawn between
                  // the starting point and the current mouse location.)
             if (dragging == true)  // Ignore mouse presses that occur
                 return;            //    when user is already drawing a curve.
                                    //    (This can happen if the user presses
                                    //    two mouse buttons at the same time.)
             prevX = startX = evt.getX();  // Save mouse coordinates.
             prevY = startY = evt.getY();
             figure = figureChoice.getSelectedIndex();
             dragColor = getCurrentColor();        
             dragGraphics = OSI.getGraphics();
             dragGraphics.setColor(dragColor);
             dragging = true;  // Start drawing.
          } // end mousePressed()
          public void mouseReleased(MouseEvent evt) {
                  // Called whenever the user releases the mouse button.
                  // If the user was drawing a shape, we make the shape
                  // permanent by drawing it to the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              dragging = false;
              mouseX = evt.getX();
              mouseY = evt.getY();
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs
                  drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                  repaintRect(prevX,prevY,mouseX,mouseY);
              else if (figure == LINE) {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX || mouseY != startY) {
                       // Draw the line only if it has non-zero length.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              else {
                 repaintRect(startX,startY,prevX,prevY);
                 if (mouseX != startX && mouseY != startY) {
                       // Draw the shape only if both its height
                       // and width are both non-zero.
                    drawFigure(dragGraphics,figure,startX,startY,mouseX,mouseY);
                    repaintRect(startX,startY,mouseX,mouseY);
              dragGraphics.dispose();
              dragGraphics = null;
          public void mouseDragged(MouseEvent evt) {
                   // Called whenever the user moves the mouse while a mouse button
                   // is down.  If the user is drawing a curve, draw a segment of
                   // the curve on the off-screen image, and repaint the part
                   // of the panel that contains the new line segment.  Otherwise,
                   // just call repaint and let paintComponent() draw the shape on
                   // top of the picture in the off-screen image.
              if (dragging == false)
                 return;  // Nothing to do because the user isn't drawing.
              mouseX = evt.getX();   // x-coordinate of mouse.
              mouseY = evt.getY();   // y=coordinate of mouse.
              if (figure == CURVE) {
                     // A CURVE is drawn as a series of LINEs.
                 drawFigure(dragGraphics,LINE,prevX,prevY,mouseX,mouseY);
                 repaintRect(prevX,prevY,mouseX,mouseY);
              else {
                    // Repaint two rectangles:  The one that contains the previous
                    // version of the figure, and the one that will contain the
                    // new version.  The first repaint is necessary to restore
                    // the picture from the off-screen image in that rectangle.
                 repaintRect(startX,startY,prevX,prevY);
                 repaintRect(startX,startY,mouseX,mouseY);
              prevX = mouseX;  // Save coords for the next call to mouseDragged or mouseReleased.
              prevY = mouseY;
          } // end mouseDragged.
          public void mouseEntered(MouseEvent evt) { }   // Some empty routines.
          public void mouseExited(MouseEvent evt) { }    //    (Required by the MouseListener
          public void mouseClicked(MouseEvent evt) { }   //    and MouseMotionListener
          public void mouseMoved(MouseEvent evt) { }     //    interfaces).
       } // end nested class Display

  • Please help! Image only shows when i use Applets instead of Frame/JFrame

    The following classes don't work because the Canvas shows just background colour. However, when I let my class "MyContainer" extend Applet instead(and running the Applet instead of the StartUp class that creates a JFrame) of Frame/JFrame i get my Image on the Canvas showing, WHY?
    code:
    public class StartUp {
    public static void main(String[] arg) {
    MyContainer my = new MyContainer();
         my.setSize(500, 400);
         my.setVisible(true);
    public class MyContainer extends JFrame {
    MyCanvas m;
    public void MyContainer() {
         m=new MyCanvas();
         this.setSize(320, 320);
    this.setLayout(new GridLayout(1, 1, 0, 0));
    this.add(m);
    this.setVisible(true);
    public class MyCanvas extends Canvas {
    Image im;
    public MyCanvas() {
    im=Toolkit.getDefaultToolkit().createImage("c:\\miniferrari.jpg");
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    public void paint(Graphics g) {
    g.drawImage(im, 0, 0, this);
    private void jbInit() throws Exception {
    this.setBackground(Color.darkGray);

    as you are using a JFrame, you should refer to it's contentpane:
    this.getContentPane().setLayout(new GridLayout(1, 1, 0, 0));
    this.getContentPane().add(m);

  • From Jframe to applet

    Hi everyone.I need to convert graphics from JFrame to Japplet. I am using a class which contains the main method the main method runs the constructor of my class and the constructor creates a new object which is a class that extends to Jframe.I need to make this program to run in an Internet Explorer.Any ideas Please help me guys It is impossible to change the whole program. Thanx in advance.

    Your JFrame extended class functionality should be put into the JApplet's
    functionality. Probably mostly in the init method.
    You could launch JFrames from within an Applet. But I'm not sure why
    you wouldn't just migrate everything your JFrame does.

  • Is correct? Application (JFrame) to Applet (JApplet)

    I need to convert a java application (JFrame) into an applet (JApplet), and I have seen a few "big steps":
    1�: make the class extends to JApplet instead of a JFrame
    2�: To replace the construction method by init ()
    3�: To comment the main method
    Is correct?, because I have some doubts that later I�ll explain
    Thanks

    I think in the init method (in a JApplet) I cannot call the super method. but my problem is how to change this? if in others files (in Files.java) I have calls to super metod, because thus it constructs a dialog box, asking for a file.
    In file Files.java I have a class called "Abort" (extends to JDialog) in whitch:
    /* class Files.java */
    class Abort extends JDialog
              boolean abort = true;
              JTextArea mensage = null;
              JButton acept = new JButton("Acept");
              JButton cancel = new JButton("Cancel");
              Abort(String nanemFile)
                   super(MainClassFile.mainWindow, " Attention!", true);
    /* clas Files.java */Please help

  • Open a JFrame from an applet

    I have an applet in which I have a JButton.
    When you click the button, I want a new window to open with a JFrame. Is that possile?
    I've written as follow but nothing happens when I click the button.
    1. In the applet, I've written:
    public class MyApplet extends Applet {
    if (e.getActionCommand() == myButton) {
    frame.getContentPane().add(new Blabla(), BorderLayout.CENTER);
    2. In the frame, I've written:
    public class Blabla extends JFrame {

    Thanks.
    Now a new window is opened when I click the button, but it's empty....
    In the frame I have a container, is that a problem? I don't know where to put "your":
    "getContentPane().setLayout(new BorderLayout());"
    I've written:
    public class Blabla extends JFrame {
    boolean inAnApplet = true;
    private boolean laidOut = false;
    private JButton b1, b2, b3;
    private JLabel fnamn;
    public Blabla() {
    Container contentPane = getContentPane();
    contentPane.setLayout(null);
    b1 = new JButton("some text");
    contentPane.add(b1);

  • How to keep applet's JFrame alive as browser's closed or, goes to other URL

    My applet has a JFrame that pops up when the applet is downloaded. Right now, if the browser goes to a different page or, if it is closed, the frame disappears.
    I would like to know how to keep the frame alive.
    Thanks.

    These comments applies to using the Applet PlugIn.
    One annoying thing about using the PlugIn is that every time you browse from your applet's page and return, it is destroyed and reinstantiated and then init'ed instead of just stop and start applied on the same applet object. One solution to maintaining state across multiple instances is to use static data. Here is an example that does this with a JFrame, since that is what the poster mentioned, although I usually just do this for the UI on the web page itself.
    This doesn't keep the frame visible when off the web page, but that seems to go against basic applet behavior.
    --Nax
    public class Applet1 extends JApplet
    {     private static JTextArea ui = new JTextArea();
         public void init()
         {     JFrame f = new JFrame("example");
              JScrollPane sp = new JScrollPane(ui);
              f.getContentPane().add(sp);
              f.setSize(200,200);
              f.setVisible(true);
    }

  • Open an applet inside a JFrame?

    Hi all!
    I know this subject is kind of covered in previous topics, but my situation here is a little different.
    I have a TRENDnet TV-IP100 Internet Camera that uses a Java-Applet to show in a browser window the video it captures, using an xview.class file.
    I built a swing application that extends JFrame and I want to open in a JPanel, inside the JFrame, the applet-class that my camera uses.
    My problem is that I can't take and decompile that class file from the camera, in order to compile from the scratch the Applet; some could say illegal.
    So, I wonder if there is a way to open the class file inside my JFrame application. Also, I want to know if I can pass argumets in the JFrame file, like PARAM, NAME, VALUE, as there are important to start the applet.
    Thank you all, in advance.
    John_Astralidis.

    I have not tried this but if the Applet or JApplet class is to be used only as far as a component in a Container (JFrame.getContentPane() returns a Container) I see no problem with explicitly casting into a Panel or even a Container
    Panel p=(Panel)theAppletInstance;
    this.getContentPane().add(p);//this being the JFrame;There be problem of which I have not considered as the applet class is 'different' to many classes.
    Bamkin
    Message was edited by:
    bamkin-ov-lesta
    Container and Panel examples were used as Applet is derived from Panel, which is derived from Containter

  • JFrames withous status bar with "Java Applet Window" ?

    Hello.
    I call a JFrame from JApplet. All my JFrames with a status bar where string "Java Applet Window" is showing. How can I creat JFrames without that status bar?
    Thank you in advance.

    This shows as a security measure because your applet isn't "signed". Your applet must be signed in order for this to not show.
    Refer to the following for a how-to:
    http://java.sun.com/developer/qow/archive/167/index.jsp

Maybe you are looking for