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

Similar Messages

  • I am on windows 8 platform, i used adobe elements to work on my image - the output is in dng format, how do i convert this to jpg format?

    i am on windows 8 platform, i used adobe elements to work on my image - the output is in dng format, how do i convert this to jpg format?

    When you make a DNG that's like making another raw file, so you will need to convert the DNG file just like your original raw. Don't use the Save button in the raw converter. That's just a link to the DNG converter. Normally you would click Open instead and then save in the editor as a jpg or other image format of your choice.

  • I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    You can't.

  • I was using time capsule to extend a network.  now i want it to be the primary base station.  how do i convert this?

    i was using time capsule to extend a network.  now i want it to be the primary base station.  how do i convert this?

    Thanks for the info. Since this is a cable modem, you will need to fully reset it so that it will associate correctly with the Time Capsule when it is reconnected.
    I don't have the manual for your Ubee model handy, but most modems will reset if you power them down completely. That means pulling the power cord from the back of the device or unplugging from the wall. Leave the modem powered off at least 30 minutes...longer will not hurt a bit.
    Next, perform a Factory Default Reset on the Time Capsule per this document:
    Resetting an AirPort Base Station or Time Capsule FAQ
    After the modem has been powered down and Time Capsule has been reset, connect an Ethernet cable from the modem to the WAN port (circle icon) on the Time Capsule.
    Power up the modem and let it run for 2-3 minutes by itself
    Then power up the Time Capsule and let it run a minute or two
    Next, open AirPort Utility and configure the Time Capsule to "Create a wireless network". Let us know what operating system you are using on your Mac or PC if you have additional questions or need more details on this.

  • How can i convert this data(00000000) into date format(yyyy-MM-dd)

    Hi,
    i am using this method to convert date format from string.
    public static string FormatDate(string inputDate, string inputFormat)
                System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
                string datepresent = DateTime.Now.Date.ToString("yyyy-MM-dd");
                return datepresent;
    its working properly,
    but when input data is like 00000000 i am getting error this is not valid.
    how can i convert this into date format any help..!

    Have you tried the above code:
    I can see it is working with both Date and DateTime destination nodes.
    Map:
    Functoid Parameters:
    Functoid Script:
    public static string FormatDate(string inputDate, string inputFormat)
    string datepresent;
    if (inputDate == "00000000")
    datepresent = "0000-00-00";
    else
    System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
    datepresent = date.ToString("yyyy-MM-dd");
    return datepresent;
    Input:
    <ns0:InputDateString xmlns:ns0="http://DateFormat.SourceSchema">
    <DateString>00000000</DateString>
    </ns0:InputDateString>
    Output:
    <ns0:OutputDate xmlns:ns0="http://DateFormat.DestinationSchema">
    <Date>0000-00-00</Date>
    </ns0:OutputDate>
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

  • How can I convert output data (string?) from GPIB-read to an 1D array?

    Hello all,
    I am reading a displayed waveform from my Tektronix Oscilloscope (TDS3032) via the GPIB Read VI. The format of the waveform data is: positive integer data-point representation with the most significant byte transferred first (2 bytes per data point).
    The output data of GPIB-Read looks like a string(?) where the integer numbers and a sign like the euro-currency sign are seperated by spaces e.g. #5200004C3 4 4 4 4 3C3C3........ (C represents the euro-currency sign).
    How can I convert this waveform data into a 1D/2D array of real double floatingpoint numbers (DBL) so I can handle the waveform data for data-analysis?
    It would be very nice if someone know the solution for this.
    t
    hanks

    Hi,
    First of all, I'm assuming you are using LabVIEW.
    The first you need to do is parse the string returned by the instrument. In this case you need to search for the known symbols in the string (like the euro sign) and chop the string to get the numeric strings. Here are some examples on parsing from www.ni.com:
    Keyword Search: parsing
    Once you parse the numeric strings you can use the "String/number conversion VIs" in the String pallette.
    Hope this helps.
    DiegoF.Message Edited by Molly K on 02-18-2005 11:01 PM

  • I got my i phone4s few days back and i created an apple id with a credit card and when i go to the appstore to purchase apps,all have and message stating that "this app is no longer availabe"..how do i fix this issue?im from singapore by the way

    i got my i phone4s few days back and i created an apple id with a credit card and when i go to the appstore to purchase apps,all have and message stating that "this app is no longer available"..how do i fix this issue?im from singapore by the way

    If it is longer available then you can't get the app on your phone.

  • TS1702 I have a charge on my CC that does not track to any purchases nor do I have an email receipt.  Can anyone tell me where/how I can get this deleted (charge is from 04/08 so nearly two weeks old)?  Thanks!

    I have a charge on my CC that does not track to any purchases nor do I have an email receipt.  Can anyone tell me where/how I can get this deleted (charge is from 04/08 so nearly two weeks old)?  Thanks!

    Apple could not tell you who else might be using your credit card, so there's no point in trying to contact them. All they could discuss with you is your own iTunes Store account, and if there's nothing in your purchase history, the charges almost certainly aren't coming from there. Again, you should take this up with your bank/credit card company and report these charges as fraudulent. They probably will cancel your card and issue you a new one.
    Regards.

  • In Preview, when I add text annotations to my PDF (lecture note slides), they look fine until I close it and reopen it, and then they are rotated 90 degrees. How do I fix this and keep it from happening again?

    In Preview, when I add text annotations to my PDF (lecture note slides), they look fine until I close it and reopen it, and then they are rotated 90 degrees. How do I fix this and keep it from happening again?

    I have the same problem with lectures slides.
    Furthermore, sometimes the text box, when doube-clicking, turns  the text into a one-liner. Causing the text box to sometimes get 3. times wider than the pdf itself.
    tcrother wrote:
    ... then when it rotates the text isn't visible and I'm stuck clicking on random parts of my lecture slides hoping the text box will come back. ...
    By pressing [cmd + I] the Inspector opens up and clicking on the rightmost tab 'Annotations' you should be able find those Annotations again. I do this regularly to find the empty annotations I accidentally create while clicking through slides.

  • Background noise removal takes about 3 seconds into each clip in timeline to kick in, so each clip has noise in the first few seconds.  How do you get this to remove noise from the very start of the clip?

    Background noise removal takes about 3 seconds into each clip in timeline to kick in, so each clip has noise in the first few seconds.  How do you get this to remove noise from the very start of the clip?

    insert a 5 second gap in the beginning of the timeline.

  • How do I convert my Raw Filws taken from my new Nikon d750 camera using Photoshop Elements 11??

    How do I convert my Raw Filws taken from my new Nikon d750 camera using Photoshop Elements 11??How do I convert my

    The D750 isn't yet supported. It may be a few weeks before Adobe provides an update for the latest versions of Photoshop/Elements. Maybe October/November.
    They usually provide a pre-release version a few weeks beforehand (any day now, hopefully), but AFAIK they don't usually work on Photoshop Elements.

  • HT204406 How can I subscribe to Itunes Match redeeming from itunes card instead of using credit card?

    How can I subscribe to itunes Match redeeming from itunes card instead of using credit card?

    Do you have another device (eg a computer) that also contains your music? If so, yes, you can turn off iTunes match and sync everything with a cable. Do you tend to buy new music from downloads or ripping CDs? If downloads, you can turn on "download purchases automatically" on the phone to make them available to you there, once you've cable-synced your current library. If CDs, you would have to manually sync with cable (or over local wifi) each time you add a new CD.
    Matt

  • How do I convert an applet to a standalone application.

    Hi Everyone,
    I am currently working on this Applet, I have tried putting the main in and building a frame to hold the applet but everytime I try something I just get new errors, What I conclusively want to do is put the applet in a frame and add menus to the frame. I have listed the code below, its quite a lot, I hope someone can help though, am pulling hair out.
    Many Thanks. Chris
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
      public class SciCalc extends Applet implements ActionListener
      // Entered a UID due to String conversion
        private static final long serialVersionUID = 1;
           int Counter;           //Counts the number of digits entered
           double Result;           //The answer displayed, as well as the second
                                 //operator taken for an operation
           double Operand;          //The first number entered for an operation
           double Mem;            //The variable which holds whatever value the user
                                 //wants kept in "memory"
           boolean DecimalFlag;       //The 'flag' that will signify whether or not the
                                 //decimal button has been pressed
           boolean SignFlag;        //The 'flag' that will signify whether or not the
                                 //plus/minus button has been pressed
           boolean OperatorKey;       //The 'flag' that will signify whether or not any
                                 //operator button has been pressed
           boolean FunctionKey;       //The 'flag' that will signify whether or not any
                        //function button has been pressed
           boolean Rad,Grad,Deg;     //The 'flags' that will signify that Rad, Grad or
                        //deg has been pressed
           int Operator;          //an integer value to indicate which operator
                                 //button was pressed
         char currchar;           //a character to hold the value of the key most
                                 //recently pressed
           String GrStatus;         //String to hold the status of various graphic
                                 //operations of the program
           String Status;           //String to hold the status of various parts
                                 //of the program
    //     LABEL DECLARATIONS 
         //This label will display all error messages
           Label DisplError = new Label(" ",Label.CENTER);
           //This label is just to the left of the Display Label lcdDisplay, and will
           //indicate whether or not a value is being held in the calculator's "memory"
           Label LabelMem = new Label(" ",Label.LEFT);
           Label LabelRad = new Label(" ",Label.CENTER);
           Label LabelDeg = new Label(" ",Label.CENTER);
           Label LabelGrad = new Label(" ",Label.CENTER);
         //This is the Display Label, which is declared as a label so the user will not
            //be able to enter any text into it to possibly crash the calculator
           Label lcdDisplay = new Label("0",Label.RIGHT);
           Label SciCalc = new Label ("Sci Calc V1.0",Label.CENTER);
    //      END OF LABEL DECLARATIONS 
    public void surround (Graphics g){
        g.setColor(new Color(0,0,0));
        g.drawRect(0,0,350,400);
    //      DELCLARATION OF NUMERIC BUTTONS
           Button button1 = new Button("1");
           Button button2 = new Button("2");
           Button button3 = new Button("3");
           Button button4 = new Button("4");
           Button button5 = new Button("5");
           Button button6 = new Button("6");
           Button button7 = new Button("7");
           Button button8 = new Button("8");
           Button button9 = new Button("9");
           Button button0 = new Button("0");
    //      END OF NUMERIC BUTTON DECLARATION
    //     DECLARATION OF OPERATOR BUTTONS
           Button buttonMinus      = new Button("-");
           Button buttonMultiply   = new Button("x");
           Button buttonPlus       = new Button("+");
           Button buttonEquals     = new Button("=");
           Button buttonDivide     = new Button("�");
           Button buttonClear      = new Button("C");
           Button buttonDecimal    = new Button(".");
           Button buttonMPlus      = new Button("M+");
           Button buttonMClear     = new Button("MC");
           Button buttonMRecall       = new Button("MR");
    //     END OF OPERATOR BUTTON DECLARATION 
    //     SCIENTIFIC BUTTON DECLARATION
           Button buttonPi            = new Button("Pi");
           Button buttonSqrt       = new Button("Sqrt");
           Button buttonCbrt       = new Button("Cbrt");
           Button buttonx2            = new Button("x2");
           Button buttonyX         = new Button("yX");
           Button buttonPlusMinus  = new Button("+-");
           Button buttonRad        = new Button("RAD");
           Button buttonGrad       = new Button("GRAD");
           Button buttonDeg        = new Button("DEG");
           Button buttonSin        = new Button("SIN");
           Button buttonCos           = new Button("COS");
           Button buttonTan        = new Button("TAN");
           Button buttonExp        = new Button("EXP");
           Button buttonLogn           = new Button("Ln");
           Button buttonOpenBracket  = new Button("(");
           Button buttonLog        = new Button("log");
    //     END OF SCIENTIFIC BUTTON DECLARATION
    //     START OF INIT METHOD
    //This the only method that is called explicitly -- every other method is
    //called depending on the user's actions.
    public void init()
    //Allows for configuring a layout with the restraints of a grid or
    //something similar
         setLayout(null);
             //APPLET DEFAULTS
        //This will resize the applet to the width and height provided
             resize(350,400);
        //This sets the default font to Helvetica, plain, size 12
                  setFont(new Font("Helvetica", Font.PLAIN, 12));
        //This sets the applet background colour
                       setBackground(new Color(219,240,219));
         //END OF APPLET DEFAULTS
         //LABEL INITIALISATION     
    //Display Panel, which appears at the top of the screen. The label is
    //placed and sized with the setBounds(x,y,width,height) method, and the
    //font, foreground color and background color are all set. Then the
    //label is added to the layout of the applet.
             lcdDisplay.setBounds(42,15,253,30);
             lcdDisplay.setFont(new Font("Helvetica", Font.PLAIN, 14));
             lcdDisplay.setForeground(new Color(0,0,0));
             lcdDisplay.setBackground(new Color(107,128,128));
             add(lcdDisplay);
    //Memory Panel, which appears just to the right of the Display Panel.
    //The label is placed and sized with the setBounds(x,y,width,height)
    //method, and the font, foreground color and background color are all
    //set. Then the label is added to the layout of the applet.
             LabelMem.setBounds(20,15,20,30);
             LabelMem.setFont(new Font("Helvetica", Font.BOLD, 16));
             LabelMem.setForeground(new Color(193,0,0));
             LabelMem.setBackground(new Color(0,0,0));
             add(LabelMem);
    //Rad,Grad and Deg panels,which appear below the memory panel.
             LabelRad.setBounds(20,50,20,15);
             LabelRad.setFont(new Font("Helvetica", Font.BOLD, 8));
             LabelRad.setForeground(new Color(193,0,0));
             LabelRad.setBackground(new Color(0,0,0));
             add(LabelRad);
             LabelDeg.setBounds(20,70,20,15);
             LabelDeg.setFont(new Font("Helvetica", Font.BOLD, 8));
             LabelDeg.setForeground(new Color(193,0,0));
             LabelDeg.setBackground(new Color(0,0,0));
             add(LabelDeg);
             LabelGrad.setBounds(20,90,20,15);
             LabelGrad.setFont(new Font("Helvetica", Font.BOLD, 8));
             LabelGrad.setForeground(new Color(193,0,0));
             LabelGrad.setBackground(new Color(0,0,0));
             add(LabelGrad);
    //SciCalc v1.0 Label, this merely indicates the name.        
             SciCalc.setBounds(60,350,200,50);
             SciCalc.setFont(new Font("papyrus", Font.BOLD, 25));
             SciCalc.setForeground(new Color(0,50,191));
             SciCalc.setBackground(new Color(219,219,219));
             add(SciCalc);
         //END OF LABEL INITIALISATION
         //NUMERIC BUTTON INITIALISATION
             button1.addActionListener(this);
             button1.setBounds(42,105,60,34);
             button1.setForeground(new Color(0,0,0));
             button1.setBackground(new Color(128,128,128));
             button1.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button1);
             button2.addActionListener(this);
             button2.setBounds(106,105,60,34);
             button2.setForeground(new Color(0,0,0));
             button2.setBackground(new Color(128,128,128));
             button2.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button2);
             button3.addActionListener(this);
             button3.setBounds(170,105,60,34);
             button3.setForeground(new Color(0,0,0));
             button3.setBackground(new Color(128,128,128));
             button3.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button3);
             button4.addActionListener(this);
             button4.setBounds(42,145,60,34);
             button4.setForeground(new Color(0,0,0));
             button4.setBackground(new Color(128,128,128));
             button4.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button4);
             button5.addActionListener(this);
             button5.setBounds(106,145,60,34);
             button5.setForeground(new Color(0,0,0));
             button5.setBackground(new Color(128,128,128));
             button5.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button5);
             button6.addActionListener(this);
             button6.setBounds(170,145,60,34);
             button6.setForeground(new Color(0,0,0));
             button6.setBackground(new Color(128,128,128));
             button6.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button6);
             button7.addActionListener(this);
             button7.setBounds(42,185,60,34);
             button7.setForeground(new Color(0,0,0));
             button7.setBackground(new Color(128,128,128));
             button7.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button7);
             button8.addActionListener(this);
             button8.setBounds(106,185,60,34);
             button8.setForeground(new Color(0,0,0));
             button8.setBackground(new Color(128,128,128));
             button8.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button8);
             button9.addActionListener(this);
             button9.setBounds(170,185,60,34);
             button9.setForeground(new Color(0,0,0));
             button9.setBackground(new Color(128,128,128));
             button9.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button9);
             button0.addActionListener(this);
             button0.setBounds(106,225,60,34);
             button0.setForeground(new Color(0,0,0));
             button0.setBackground(new Color(128,128,128));
             button0.setFont(new Font("Dialog", Font.BOLD, 18));
             add(button0);
         //END OF NUMERIC BUTTON INITIALISATION        
         //OPERATOR BUTTON INITIALISATION         
             buttonDecimal.addActionListener(this);
             buttonDecimal.setBounds(42,225,60,34);
             buttonDecimal.setForeground(new Color(0,0,0));
             buttonDecimal.setBackground(new Color(254,204,82));
             buttonDecimal.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonDecimal);
             buttonPlusMinus.addActionListener(this);
             buttonPlusMinus.setBounds(106,325,60,17);
             buttonPlusMinus.setForeground(new Color(0,0,0));
             buttonPlusMinus.setBackground(new Color(0,118,191));
             buttonPlusMinus.setFont(new Font("Dialog", Font.BOLD, 16));
             add(buttonPlusMinus);
             buttonMinus.addActionListener(this);
             buttonMinus.setBounds(234,145,60,34);
             buttonMinus.setForeground(new Color(0,0,0));
             buttonMinus.setBackground(new Color(254,204,82));
             buttonMinus.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMinus);
             buttonMultiply.addActionListener(this);
             buttonMultiply.setBounds(234,225,60,34);
             buttonMultiply.setForeground(new Color(0,0,0));
             buttonMultiply.setBackground(new Color(254,204,82));
             buttonMultiply.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMultiply);
             buttonPlus.addActionListener(this);
             buttonPlus.setBounds(234,105,60,34);
             buttonPlus.setForeground(new Color(0,0,0));
             buttonPlus.setBackground(new Color(254,204,82));
             buttonPlus.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonPlus);
             buttonEquals.addActionListener(this);
             buttonEquals.setBounds(170,225,60,34);
             buttonEquals.setForeground(new Color(0,0,0));
             buttonEquals.setBackground(new Color(254,204,82));
             buttonEquals.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonEquals);
             buttonDivide.addActionListener(this);
             buttonDivide.setBounds(234,185,60,34);
             buttonDivide.setForeground(new Color(0,0,0));
             buttonDivide.setBackground(new Color(254,204,82));
             buttonDivide.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonDivide);
             buttonClear.addActionListener(this);
             buttonClear.setBounds(234,65,60,34);
             buttonClear.setFont(new Font("Dialog", Font.BOLD, 18));
             buttonClear.setForeground(new Color(0,0,0));
             buttonClear.setBackground(new Color(193,0,0));
             add(buttonClear);
             buttonMPlus.addActionListener(this);
             buttonMPlus.setBounds(170,65,60,34);
             buttonMPlus.setFont(new Font("Dialog", Font.BOLD, 18));
             buttonMPlus.setForeground(new Color(0,0,0));
             buttonMPlus.setBackground(new Color(254,204,82));
             add(buttonMPlus);
             buttonMClear.addActionListener(this);
             buttonMClear.setBounds(42,65,60,34);
             buttonMClear.setForeground(new Color(193,0,0));
             buttonMClear.setBackground(new Color(254,204,82));
             buttonMClear.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMClear);
             buttonMRecall.addActionListener(this);
             buttonMRecall.setBounds(106,65,60,34);
             buttonMRecall.setForeground(new Color(0,0,0));
             buttonMRecall.setBackground(new Color(254,204,82));
             buttonMRecall.setFont(new Font("Dialog", Font.BOLD, 18));
             add(buttonMRecall);
         //END OF OPERATOR BUTTON INITIALISATION
         // SCIENTIFIC BUTTONS INITIALISATION   
             buttonPi.addActionListener(this);
             buttonPi.setBounds(42,265,60,17);
             buttonPi.setForeground(new Color(0,0,0));
             buttonPi.setBackground(new Color(0,118,191));
             buttonPi.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonPi);
             buttonSqrt.addActionListener(this);
             buttonSqrt.setBounds(106,265,60,17);
             buttonSqrt.setForeground(new Color(0,0,0));
             buttonSqrt.setBackground(new Color(0,118,191));
             buttonSqrt.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonSqrt);
             buttonCbrt.addActionListener(this);
             buttonCbrt.setBounds(170,265,60,17);
             buttonCbrt.setForeground(new Color(0,0,0));
             buttonCbrt.setBackground(new Color(0,118,191));
             buttonCbrt.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonCbrt);
             buttonyX.addActionListener(this);
             buttonyX.setBounds(42,285,60,17);
             buttonyX.setForeground(new Color(0,0,0));
             buttonyX.setBackground(new Color(0,118,191));
             buttonyX.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonyX);
             buttonx2.addActionListener(this);
             buttonx2.setBounds(234,265,60,17);
             buttonx2.setForeground(new Color(0,0,0));
             buttonx2.setBackground(new Color(0,118,191));
             buttonx2.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonx2);
             buttonRad.addActionListener(this);
             buttonRad.setBounds(170,285,60,17);
             buttonRad.setForeground(new Color(0,0,0));
             buttonRad.setBackground(new Color(0,118,191));
             buttonRad.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonRad);
             buttonGrad.addActionListener(this);
             buttonGrad.setBounds(234,285,60,17);
             buttonGrad.setForeground(new Color(0,0,0));
             buttonGrad.setBackground(new Color(0,118,191));
             buttonGrad.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonGrad);
             buttonDeg.addActionListener(this);
             buttonDeg.setBounds(106,285,60,17);
             buttonDeg.setForeground(new Color(0,0,0));
             buttonDeg.setBackground(new Color(0,118,191));
             buttonDeg.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonDeg);
             buttonSin.addActionListener(this);
             buttonSin.setBounds(42,305,60,17);
             buttonSin.setForeground(new Color(0,0,0));
             buttonSin.setBackground(new Color(0,118,191));
             buttonSin.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonSin);
             buttonCos.addActionListener(this);
             buttonCos.setBounds(106,305,60,17);
             buttonCos.setForeground(new Color(0,0,0));
             buttonCos.setBackground(new Color(0,118,191));
             buttonCos.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonCos);
             buttonTan.addActionListener(this);
             buttonTan.setBounds(170,305,60,17);
             buttonTan.setForeground(new Color(0,0,0));
             buttonTan.setBackground(new Color(0,118,191));
             buttonTan.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonTan);
             buttonExp.addActionListener(this);
             buttonExp.setBounds(234,305,60,17);
             buttonExp.setForeground(new Color(193,0,0));
             buttonExp.setBackground(new Color(0,118,191));
             buttonExp.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonExp);
             buttonLogn.addActionListener(this);
             buttonLogn.setBounds(234,325,60,17);
             buttonLogn.setForeground(new Color(0,0,0));
             buttonLogn.setBackground(new Color(0,118,191));
             buttonLogn.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonLogn);
             buttonOpenBracket.addActionListener(this);
             buttonOpenBracket.setBounds(42,325,60,17);
             buttonOpenBracket.setForeground(new Color(0,0,0));
             buttonOpenBracket.setBackground(new Color(0,118,191));
             buttonOpenBracket.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonOpenBracket);
             buttonLog.addActionListener(this);
             buttonLog.setBounds(170,325,60,17);
             buttonLog.setForeground(new Color(0,0,0));
             buttonLog.setBackground(new Color(0,118,191));
             buttonLog.setFont(new Font("Dialog", Font.BOLD, 10));
             add(buttonLog);
         //END OF SCIENTIFIC BUTTON INITIALISATION     
         //DISPLERROR INITIALISATION      
             DisplError.setBounds(42,45,253,15);
             DisplError.setFont(new Font("Dialog", Font.BOLD, 8));
             DisplError.setForeground(new Color(16711680));
             DisplError.setBackground(new Color(0));
             add(DisplError);
         //END OF DISPLERROR INITIALISATION
             Clicked_Clear();      //calls the Clicked_Clear method (C button)
         } //END OF INIT METHOD
    //The following integers are declared as final as they will
    //be used for determining which button has been pushed
         public final static int OpMinus=11,
                                     OpMultiply=12,
                                     OpPlus=13,
                                     OpDivide=15,
                                     OpMPlus=19,
                                     OpMClear=20,
                                     OpMR=21,
                                     OpyX=22,
                                     OpExp=23;
    //This method is called whenever anything needs to be displayed
    //in the error message field at the bottom of the calculator,
    //accepting a String as an argument
      void DisplayError(String err_msg)
    //Calls the setText method of the Label DisplError, sending
    //whatever string it received initially
        DisplError.setText(err_msg);
    //This method is called whenever a numeric button (0-9) is pushed.
    public void NumericButton(int i)
         DisplayError(" ");      //Clears the error message field
    //Declares a String called Display that will initialize to whatever
    //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
    //Checks if an operator key has just been pressed, and if it has,
    //then the limit of 20 digits will be reset for the user so that
    //they can enter in up to 20 new numbers
             if (OperatorKey == true)
               Counter = 0;
             Counter = Counter + 1;    //increments the counter
    //This is a condition to see if the number currently displayed is zero OR
    //an operator key other than +, -, *, or / has been pressed.
             if ((Display == "0") || (Status == "FIRST"))
               Display= "";      //Do not display any new info
             if (Counter < 21)     //if more than 20 numbers are entered
    //The number just entered is appended to the string currently displayed
         Display = Display + String.valueOf(i);
             else
    //call the DisplayError method and send it an error message string
         DisplayError("Digit Limit of 20 Digits Reached");
         lcdDisplay.setText(Display);       //sets the text of the lcdDisplay          
                                       //Label
        Status = "VALID";            //sets the Status string to valid
        OperatorKey = false;           //no operator key was pressed
        FunctionKey = false;           //no function key was pressed
    //This method is called whenever an operator button is pressed, and is   
    //sent an integer value representing the button pressed.
           public void OperatorButton(int i)
         DisplayError(" ");      //Clears the error message field
    //Creates a new Double object with the specific purpose of retaining
    //the string currently on the lcdDisplay label, and then immediately
    //converts that string into a double-precision real number and then
    //gives that number to the variable Result.
             Result = (new Double(lcdDisplay.getText())).doubleValue();
    //If no operator key has been pressed OR a function has been pressed
         if ((OperatorKey == false) || (FunctionKey = true))
         switch (Operator)     //depending on the operation performed
    //if the user pressed the addition button, add the two numbers
    //and put them in double Result
            case OpPlus     : Result = Operand + Result;
                      break;
    //if the user pressed the subtraction button, subtract the two
    //numbers and put them in double Result
         case OpMinus    : Result = Operand - Result;
                      break;
    //if the user pressed the multiplication button, multiply
    //the two numbers and put them in double Result
            case OpMultiply : Result = Result * Operand;
                      break;
    //if the user pressed the yX button, take first number
    //and multiply it to the power of the second number                 
         case OpyX : double temp1=Operand;
                        for (int loop=0; loop<Result-1; loop++){
                              temp1= temp1*Operand;
                        Result=temp1;
                      break;
    //if the user pressed the Exp button -----------------Find out what this does-------------         
         case OpExp :  temp1=10;
                          for(int loop=0; loop<Result-1; loop++)
                          temp1=temp1*10;
                           Result=Result*temp1;
                     break;
    //if the user pressed the division button, check to see if
    //the second number entered is zero to avoid a divide-by-zero
    //exception
            case OpDivide   : if (Result == 0)
                        //set the Status string to indicate an
                        //an error
                        Status = "ERROR";
                        //display the word "ERROR" on the
                        //lcdDisplay label
                        lcdDisplay.setText("ERROR");
                        //call the DisplayError method and
                        //send it a string indicating an error
                        //has occured and of what type
                        DisplayError("ERROR: Division by Zero");
                      else
                        //divide the two numbers and put the
                        //answer in double Result
                   Result = Operand / Result;
    //if after breaking from the switch the Status string is not set
    //to "ERROR"
              if (Status != "ERROR")
            Status = "FIRST";      //set the Status string to "FIRST" to
                                 //indicate that a simple operation was
                                 //not performed
            Operand = Result; //Operand holds the value of Result
            Operator = i;   //the integer value representing the
                            //operation being performed is stored
                            //in the integer Operator
            //The lcdDisplay label has the value of double Result
            //displayed
         lcdDisplay.setText(String.valueOf(Result));
            //The boolean decimal flag is set false, indicating that the
            //decimal button has not been pressed
         DecimalFlag = false;
            //The boolean sign flag is set false, indicating that the sign
            //button has not been pressed
         SignFlag = false;
            //The boolean OperatorKey is set true, indicating that a simple
            //operation has been performed
         OperatorKey = true;
            //The boolean FunctionKey is set false, indicating that a
            //function key has not been pressed
         FunctionKey = false;
            DisplayError(" ");    //Clears the error message field
      }     //end of OperatorButton method
      //This is a method that is called whenever the decimal button is
      //pressed.
      public void DecimalButton()
        DisplayError(" ");    //Clears the error message field
      //Declares a String called Display that will initialize to whatever
      //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
        //if a simple operation was performed successfully
         if (Status == "FIRST")
          Display = "0";    //set Display string to character 0
        //If the decimal button has not already been pressed
         if (!DecimalFlag)
          //appends a decimal to the string Display
          Display = Display + ".";
        else
               //calls the DisplayError method, sending a string
               //indicating that the number already has a decimal
          DisplayError("Number already has a Decimal Point");
             //calls the setText method of the Label lcdDisplay and
              //sends it the string Display
        lcdDisplay.setText(Display);
         DecimalFlag = true;        //the decimal key has been pressed
             Status = "VALID";        //Status string indicates a valid
                               //operation has been performed
        OperatorKey = false;         //no operator key has been pressed
      } //end of the DecimalButton method
      /* This method is called whenever the percent button is pressed
      void Open_Bracket(){
        String Display = "(";
        lcdDisplay.setText(Display);//-----------Change this--------------
    //This method is called first when the calculator is initialized
    //with the init() method, and is called every time the "C" button
    //is pressed
      void Clicked_Clear()
        Counter = 0;        //sets the counter to zero
        Status = "FIRST";   //sets Status to FIRST
        Operand = 0;        //sets Operand to zero
        Result = 0;         //sets Result to zero
        Operator = 0;       //sets Operator integer to zero
        DecimalFlag = false;         //decimal button has not been
                                     //pressed
        SignFlag = false;          //sign button has not been pressed
        OperatorKey = false;         //no operator button has been
                                //pressed
        FunctionKey = false;         //no function button has been
                                //pressed
    //calls the setText method of Label lcdDisplay and sends
    //it the character "0"
        lcdDisplay.setText("0"); 
        DisplayError(" ");           //clears the error message field
    //This method is called whenever the sign button is pressed
         void PlusMinusButton()
        DisplayError(" ");           //clears the error message field
    //Declares a String called Display that will initialize to whatever
    //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
    //if Status is not set to FIRST and the Display string does not
    //hold the value "0"
        if ((Status != "FIRST") || (Display != "0"))
    //Creates a new Double object with the specific purpose of retaining
    //the string currently on the lcdDisplay label, and then immediately
    //converts that string into a double-precision real number and then
    //gives that number to the variable Result.
          Result = (new Double(lcdDisplay.getText())).doubleValue();
          //sets the double Result to it's negative value
          Result = -Result;
          //call the setText method of Label lcdDisplay and send it the string
          //that represents the value in Result
          lcdDisplay.setText(String.valueOf(Result));
          Status = "VALID";        //sets Status string to VALID
          SignFlag = true;         //the sign button has been pressed
          DecimalFlag = true;        //a decimal has appeared
      } //end of the PlusMinusButton method
    //This method is called whenever the square button is pressed */
         void SqrButton()
        DisplayError(" ");      //clears the error message field
    //Declares a String called Display that will initialize to whatever
    //is currently displayed in the lcdDisplay of the calculator
        String Display = lcdDisplay.getText();
    //if Status is not set to FIRST and the Display string does not
    //hold the value "0"
        if ((Status != "FIRST") || (Display != "0"))
    //Creates a new Double object with the specific purpose of retaining
    //the string currently on the lcdDisplay label, and then immediately
    //converts that string into a double-precision real number and then
    //gives that number to the variable Result.
          Result = (new Double(lcdDisplay.getText())).doubleValue();
    //multiply the double Result by itself, effectively squaring
    //the number
          Result = Result * Result;
    //call the setText method of Label lcdDisplay and send it the string
    //that represents the value in Result
         lcdDisplay.setText(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &

    Chris,
    Two issues:
    1) Applet has init(), start(), etc. Application has main().
    2) Applet is a container and you can add stuff to it. With application, you need to create your own container.
    What you want to do is code so that you can run either way. In the applet, create a Panel or JPanel and add everything to the panel. Then add the panel to the applet. Get that working as an applet.
    Now add a main(). All it has to do is create a Frame or JFrame, add the panel to the frame and then call init().
    On another subject, your code looks very good, except for the method length getting out of hand. Try breaking init() into pieces in a bunch of methods:
    public void init() {
       doThis();
       doThat();
       doTheOther();
    private void doThis() {
       // maybe a couple dozen lines here
    // etc.

  • White spaces issue when applet is launched from Browser

    I am trying to open HTML file (generated by net beans) to launch applet using window.open function.
    The applet is launching fine but white spaces are coming on top and left side of the applet.
    Any idea on how to remove these white spaces?

    You need a custom html template and to set the application size parameters to 100% width and height.
    Not sure if this is possible using the NetBeans JavaFX project configuration options currently.
    Have a look at the Ensemble sample and Ensemble sample code, it implements a custom html template and 100% size parameters.
    http://www.oracle.com/technetwork/java/javafx/samples/index.html
    A css reset will remove default padding from an html page.
    http://yuilibrary.com/yui/docs/cssreset/
    <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.6.0/build/cssreset/cssreset-min.css">
    The minimal reset required to remove margins around the edge of the page is:
    html, body { 
        margin: 0; 
        overflow: hidden; 
        padding: 0;
    }Documentation is on web based deployment templates and application size is:
    http://docs.oracle.com/javafx/2/deployment/deployment_toolkit.htm#BABJHEJA
    Note it doesn't talk about percentage sizes as this may be an undocumented feature, but I think if you set the width and height in the dtjava.App call to '100%', the app will fill the available area of a window.
    A view source on the ensemble html =>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JavaFX 2.0 - Ensemble</title>
    <SCRIPT src="./web-files/dtjava.js"></SCRIPT>
    <script>
        function javafxEmbed_ensemble() {
            dtjava.embed(
                    id : 'ensemble',
                    url : 'Ensemble.jnlp',
                    placeholder : 'javafx-app-placeholder',
                    width : '100%',
                    height : '100%',
                    jnlp_content : 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxqbmxwIHNwZWM9IjEuMCIgeG1sbnM6amZ4PSJodHRwOi8vamF2YWZ4LmNvbSIgaHJlZj0iRW5zZW1ibGUuam5scCI+DQogIDxpbmZvcm1hdGlvbj4NCiAgICA8dGl0bGU+RW5zZW1ibGU8L3RpdGxlPg0KICAgIDx2ZW5kb3I+ZGVtbzwvdmVuZG9yPg0KICAgIDxkZXNjcmlwdGlvbj5TYW1wbGUgSmF2YUZYIDIuMCBhcHBsaWNhdGlvbi48L2Rlc2NyaXB0aW9uPg0KICAgIDxvZmZsaW5lLWFsbG93ZWQvPg0KICA8L2luZm9ybWF0aW9uPg0KICA8cmVzb3VyY2VzPg0KICAgIDxqZng6amF2YWZ4LXJ1bnRpbWUgdmVyc2lvbj0iMi4yKyIgaHJlZj0iaHR0cDovL2phdmFkbC5zdW4uY29tL3dlYmFwcHMvZG93bmxvYWQvR2V0RmlsZS9qYXZhZngtbGF0ZXN0L3dpbmRvd3MtaTU4Ni9qYXZhZngyLmpubHAiLz4NCiAgPC9yZXNvdXJjZXM+DQogIDxyZXNvdXJjZXM+DQogICAgPGoyc2UgdmVyc2lvbj0iMS42KyIgaHJlZj0iaHR0cDovL2phdmEuc3VuLmNvbS9wcm9kdWN0cy9hdXRvZGwvajJzZSIvPg0KICAgIDxqYXIgaHJlZj0iRW5zZW1ibGUuamFyIiBzaXplPSI4ODQ4MTU0IiBkb3dubG9hZD0iZWFnZXIiIC8+DQogIDwvcmVzb3VyY2VzPg0KICA8YXBwbGV0LWRlc2MgIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBtYWluLWNsYXNzPSJjb20uamF2YWZ4Lm1haW4uTm9KYXZhRlhGYWxsYmFjayIgIG5hbWU9IkVuc2VtYmxlIiA+DQogICAgPHBhcmFtIG5hbWU9InJlcXVpcmVkRlhWZXJzaW9uIiB2YWx1ZT0iMi4yKyIvPg0KICA8L2FwcGxldC1kZXNjPg0KICA8amZ4OmphdmFmeC1kZXNjICB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgbWFpbi1jbGFzcz0iZW5zZW1ibGUuRW5zZW1ibGUyIiAgbmFtZT0iRW5zZW1ibGUiIC8+DQogIDx1cGRhdGUgY2hlY2s9ImJhY2tncm91bmQiLz4NCjwvam5scD4NCg=='
                    javafx : '2.2+'
        <!-- Embed FX application into web page once page is loaded -->
        dtjava.addOnloadCallback(javafxEmbed_ensemble);
    </script>
            <style>
                html, body { 
                    margin: 0; 
                    overflow: hidden; 
                    padding: 0;
            </style>
            <script>
                function hashchanged(event) {
                    var applet = document.getElementById('ensemble');
                    if (applet != null) {
                        try {
                            applet.hashChanged(location.hash);
                        } catch (err) {
                            console.log("JS Exception when trying to pass hash to Ensmeble Applet: " + err);
            </script>
    </head>
    <body onhashchange="hashchanged(event)"><div id='javafx-app-placeholder'></div></body>
    </html>

  • How can a locally installed application br launched from a browser

    Hi
    I want to launch a locally installed java based swing application from my browser. How can I do this.
    BR
    Omair

    Maybe I'm wrong, but as far as I concern, you can't. However, If you're trying to acomplish it using an enterprise or a web application, you could test something like this at some point of your source code:
    Process swingProcess = Runtime.getRuntime().exec(new String[]{"java", "-Xmx=256m", "-jar" "-cp", "<classpath-jars-dirs>", "mySwingApp.jar"});
    Hope this helps...

Maybe you are looking for

  • Abap Routine for Date selection in Infopackage

    Hi I have to write an abap routine for date selections in the infopackage, There are two date begda and enda. Do i code for BEGDA and fill in the begin date using routine and use another routine to fill the ENDA. JPJP

  • Caught in a loop of Apple ID dialog boxes!

    I'm trying to buy stuff on the iTunes store and I get caught in a loop of dialog boxes asking me for my Apple ID. I enter my Apple ID, but it just results in a new dialog box. The sequence of dialog boxes was the following: - Sign in to the iTunes st

  • Others can hear a ton of background noise when talking on the iphone 5

    When I'm using my headset to talk with others the background noise is extremely loud.  I have tried the earpods that came with the phone and the background noise cuts in and out and have tried Bose headsets and the noise sounds awaful....like a wind

  • Could not sign in via ovi suite (3.1.0.91)

    Hi There, I am not able to login to Nokia accounts  via ovi suite. Seems to be some sort of internet connection/setting issue, although I can browser,etc via same internet connection from my PC perfectly fine. Screenshot is attached... Thank you, Yog

  • Upgrade from 12.1 to 12.1.3 (forms not starting)

    Hi all, I just upgraded our server from R12.1 to R12.1.3. I am able to login but forms is not starting. I get this error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Plea