Converting an applet into a frame

hello.
this is james mcfadden. I am developing a 2-player BlackJack card game in java. how do i convert the following 2 pieces of code from an applet into a frame?
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Blackjack extends Applet implements ActionListener,Runnable{
     private Deck deck;     //The deck...
     private Hand player_hand;//player hand
     private Hand dealer_hand;//dealer hand.
     private Button bHit=new Button("Hit");
     private Button bStay=new Button("Stay");
     private Button bRestart=new Button("New Game");
     //lets do some double buffering.
     Image offIm=null;
     Graphics offGraphics=null;
     Dimension offDimension=null;
     Image[] card_images = new Image[52];
     private boolean cards_loaded = false;
     private int current_card_loading = 0;
     String message;                         //print a message...
     int width;          //The width of the applet
     int height;          //The height of the applet
     int card_width = -1;
     int card_padding = -1;     //How much should we pad the cards by..?
     private int games=-1;     //How many games have been played?
     public void init() {
          Thread card_loader = new Thread(this);
          card_loader.start();
     public void newGame(){
          bHit.setEnabled(true);
          bStay.setEnabled(false);
          player_hand = new Hand();     //Create new hands...
          dealer_hand = new Hand();
          //shuffle the deck.
          deck.shuffleCards();
          games++;
     public void hit(){
          bStay.setEnabled(true);
          player_hand.addCard(deck.dealCard());
          if(player_hand.getValue() > 21){
               message = "You loose! (score:"+player_hand.getValue()+")";
               //disable the hit and stay buttons...
               bHit.setEnabled(false);
               bStay.setEnabled(false);
               return;
          message = "Score: "+player_hand.getValue();     
     public void stay(){
          while(dealer_hand.getValue() < 17){
               dealer_hand.addCard(deck.dealCard());
          if(dealer_hand.getValue() <= 21 && player_hand.getValue() < dealer_hand.getValue())
               message = "You loose! (" + player_hand.getValue()+
                         " - "+dealer_hand.getValue()+")";
          }else if (player_hand.getValue() == dealer_hand.getValue())
               message = "You draw! (" + player_hand.getValue()+")";
          }else {
               message = "You win! (" + player_hand.getValue()+
                         " - "+dealer_hand.getValue()+")";
          bHit.setEnabled(false);
          bStay.setEnabled(false);
     public void actionPerformed(ActionEvent e) {
          if(e.getSource() == bRestart)
               newGame();
          }else if (e.getSource() == bHit)
               hit();
          }else if (e.getSource() == bStay)
               stay();
          repaint();
     public void paint(Graphics g) {
          update(g);
     public void update(Graphics g) {
          //lets sord out double buffering
          if(offGraphics==null){
               offIm=createImage(getSize().width,getSize().height);
               offGraphics=offIm.getGraphics();
          if(!cards_loaded){
               //display a message saying we're loading the cards...
               offGraphics.setFont(new Font("Arial",Font.PLAIN,14));
               offGraphics.setColor(new Color(171,205,239));
               offGraphics.fillRect(0,0,getSize().width,getSize().height);
               offGraphics.setColor(Color.black);
               offGraphics.drawString("Loading cards... ",5,20);
               offGraphics.drawRect(15,40, 102 ,10);
               offGraphics.drawRect(13,38, 106 ,14);
               offGraphics.setColor(new Color(171,205,239));
               offGraphics.fillRect(0,0,150,35);
               offGraphics.setColor(Color.black);
               offGraphics.fillRect(15,40, (current_card_loading)*2 ,10);
               offGraphics.drawString("Loading card: "+current_card_loading+1,15,20);
          }else{
               Image currentCard;
               while(card_width == -1)
                    card_width = deck.getCard(0).getImage().getWidth(this);
               if(card_padding == -1)
                    card_padding = (width - (card_width * 2) - 4) / 4;
               //clear the background...
               offGraphics.setColor(Color.blue);
               offGraphics.fillRect(0,0,width,height);
               offGraphics.setColor(Color.black);
               offGraphics.fillRect(1,1,width-2,height-2);
               offGraphics.setColor(Color.white);
               offGraphics.drawString("PLAYER:",card_padding,40);
               offGraphics.drawString("DEALER:",(width/2) + card_padding,40);
               offGraphics.drawString(message,5,height - 20);
               if(games > 0)
                    offGraphics.drawString(games + " game(s) played...",5,height - 10);
               //Draw the players hand...
               for(int i=0;i<player_hand.getCardCount();i++){
                    currentCard = player_hand.getCards().getImage();
                    offGraphics.drawImage(currentCard, card_padding, 70+(20*(i-1)), this);
               //now draw the dealers hand...
               for(int i=0;i<dealer_hand.getCardCount();i++){
                    currentCard = dealer_hand.getCards()[i].getImage();
                    offGraphics.drawImage(currentCard, (width/2 ) + card_padding, 70+(20*(i-1)), this);
          //draw buffered image.
          g.drawImage(offIm,0,0,this);
public void run(){
          MediaTracker t=new MediaTracker(this);
          System.out.println("Applet getting cards...");
          for(current_card_loading=0; current_card_loading < 52; current_card_loading++){
          //try{
               card_images[current_card_loading] = getImage(getCodeBase(),
                                                            "cards/" + (current_card_loading+1) + ".gif");
               if(card_images[current_card_loading] == null){
                    System.out.println("Null card... ["+current_card_loading+"]");
               }else{
                    t.addImage(card_images[current_card_loading],0);
               try{
                    t.waitForID(0);
               }catch(InterruptedException e){
                    System.err.println("Interrupted waiting for images..>");
               //lets show our new status.
               repaint();
          //create the deck object now
          deck = new Deck(this,card_images);     //Create a new deck object.
          card_width = deck.getCard(0).getImage().getWidth(this);
          bHit.addActionListener(this);
          bStay.addActionListener(this);
          bRestart.addActionListener(this);
          bHit.setEnabled(false);
          bStay.setEnabled(false);
          width = getSize().width;
          height = getSize().height;
          this.add(bHit);
          this.add(bStay);
          this.add(bRestart);
          player_hand = new Hand();     //Create the hands...
          dealer_hand = new Hand();
          //make sure that the buttons appear properly.
          this.validate();
          message = "";
          cards_loaded = true;
          System.out.println("End of thread...");
          repaint();
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
class Deck {
     Card[] cards = new Card[52];
     int currCard;
     public Deck(Blackjack myApplet,Image[] card_images) {
          // These are the (initial) values of all the cards
          int[] values = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
               11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
               11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
               11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10};
          // Make all the cards, getting the images individually
          for (int i=0; i<52; i++) {
//               Image image = myApplet.getImage(myApplet.getCodeBase(), "cards/" + (i+1) + ".gif");
               cards[i] = new Card(card_images, values[i]);
          // Shuffle the cards.
          shuffleCards();
     public void shuffleCards(){
          Card temp;
          //loop through each card in the deck and swap it with some random card.
          for (int i=0; i<52; i++) {
               int rand = (int)(Math.random()*52);
               temp = cards[51-i];//take the current card...
               cards[51-i] = cards[rand];//and swap it with some random card...
               cards[rand] = temp;
          //now, reset the currentCard to deal...
          currCard = 0;
     public Card dealCard() {
          Card card = cards[currCard];
          currCard++;
          return card;
     public Card getCard(int i) {
          return cards[i];

thanks for the advice.
i've done what you suggested. but when i went try to compile the 2 programs i get error messages (shown below along with the modified code). do you know what are causing these error messages?
import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Blackjack extends JFrame implements ActionListener,MouseListener{
     private Deck deck;     //The deck...
     private Hand player_hand;//player hand
     private Hand dealer_hand;//dealer hand.
     //private Button bHit=new Button("Hit");
     JButton bHit=new JButton("Hit");
     //private Button bStay=new Button("Stay");
     JButton bStay=new JButton("Stay");
     //private Button bRestart=new Button("New Game");
     JButton bRestart=new JButton("New Game");
     //lets do some double buffering.
     Image offIm=null;
     Graphics offGraphics=null;
     Dimension offDimension=null;
     Image[] card_images = new Image[52];
     private boolean cards_loaded = false;
     private int current_card_loading = 0;
     String message;                         //print a message...
     int width;          //The width of the applet
     int height;          //The height of the applet
     int card_width = -1;
     int card_padding = -1;     //How much should we pad the cards by..?
     private int games=-1;     //How many games have been played?
     public static void main(String[] args){
           Blackjack bj =new Blackjack(); 
          bj.pack();
          bj.setVisible(true);
     public Blackjack(){
        Thread card_loader = new Thread(this);
          card_loader.start();
          bHit.addMouseListener(this);
      bHit.addActionListener(this);
      //bHit.addMouseMotionListener(this);
          add(bHit);
          bStay.addMouseListener(this);
      bStay.addActionListener(this);
      //bStay.addMouseMotionListener(this);
          add(bStay);
          bRestart.addMouseListener(this);
      bRestart.addActionListener(this);
      //bRestart.addMouseMotionListener(this);
          add(bRestart);
          JFrame frame=new JFrame("BlackJack");
          frame.setSize(400,200);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(this);
        frame.pack();
        frame.setVisible(true);
     public void newGame(){
          bHit.setEnabled(true);
          bStay.setEnabled(false);
          player_hand = new Hand();     //Create new hands...
          dealer_hand = new Hand();
          //shuffle the deck.
          deck.shuffleCards();
          games++;
     public void hit(){
          bStay.setEnabled(true);
          player_hand.addCard(deck.dealCard());
          if(player_hand.getValue() > 21){
               message = "You loose! (score:"+player_hand.getValue()+")";
               //disable the hit and stay buttons...
               bHit.setEnabled(false);
               bStay.setEnabled(false);
               return;
          message = "Score: "+player_hand.getValue();     
     public void stay(){
          while(dealer_hand.getValue() < 17){
               dealer_hand.addCard(deck.dealCard());
          if(dealer_hand.getValue() <= 21 && player_hand.getValue() < dealer_hand.getValue()){
               message = "You loose! (" + player_hand.getValue()+" - "+dealer_hand.getValue()+")";
          else if (player_hand.getValue() == dealer_hand.getValue()){
               message = "You draw! (" + player_hand.getValue()+")";
          else{
               message = "You win! (" + player_hand.getValue()+" - "+dealer_hand.getValue()+")";
          bHit.setEnabled(false);
          bStay.setEnabled(false);
     public void actionPerformed(ActionEvent e){
          if(e.getSource() == bRestart){
               newGame();
          else if (e.getSource() == bHit){
               hit();
          else if (e.getSource() == bStay){
               stay();
          repaint();
     public void paint(Graphics g){
          update(g);
     public void update(Graphics g){
          //lets sord out double buffering
          if(offGraphics==null){
               offIm=createImage(getSize().width,getSize().height);
               offGraphics=offIm.getGraphics();
          if(!cards_loaded){
               //display a message saying we're loading the cards...
               offGraphics.setFont(new Font("Arial",Font.PLAIN,14));
               offGraphics.setColor(new Color(171,205,239));
               offGraphics.fillRect(0,0,getSize().width,getSize().height);
               offGraphics.setColor(Color.black);
               offGraphics.drawString("Loading cards... ",5,20);
               offGraphics.drawRect(15,40, 102 ,10);
               offGraphics.drawRect(13,38, 106 ,14);
               offGraphics.setColor(new Color(171,205,239));
               offGraphics.fillRect(0,0,150,35);
               offGraphics.setColor(Color.black);
               offGraphics.fillRect(15,40, (current_card_loading)*2 ,10);
               offGraphics.drawString("Loading card: "+current_card_loading+1,15,20);
          else{
               Image currentCard;
               while(card_width == -1){
                    card_width = deck.getCard(0).getImage().getWidth(this);
               if(card_padding == -1){
                    card_padding = (width - (card_width * 2) - 4) / 4;
               //clear the background...
               offGraphics.setColor(Color.blue);
               offGraphics.fillRect(0,0,width,height);
               offGraphics.setColor(Color.black);
               offGraphics.fillRect(1,1,width-2,height-2);
               offGraphics.setColor(Color.white);
               offGraphics.drawString("PLAYER:",card_padding,40);
               offGraphics.drawString("DEALER:",(width/2) + card_padding,40);
               offGraphics.drawString(message,5,height - 20);
               if(games > 0){
                    offGraphics.drawString(games + " game(s) played...",5,height - 10);
               //Draw the players hand...
               for(int i=0;i<player_hand.getCardCount();i++){
                    currentCard = player_hand.getCards().getImage();
                    offGraphics.drawImage(currentCard, card_padding, 70+(20*(i-1)), this);
               //now draw the dealers hand...
               for(int i=0;i<dealer_hand.getCardCount();i++){
                    currentCard = dealer_hand.getCards()[i].getImage();
                    offGraphics.drawImage(currentCard, (width/2 ) + card_padding, 70+(20*(i-1)), this);
          //draw buffered image.
          g.drawImage(offIm,0,0,this);
public void run(){
          MediaTracker t=new MediaTracker(this);
          System.out.println("Frame getting cards...");
          for(current_card_loading=0; current_card_loading < 52; current_card_loading++){
          //try{
               card_images[current_card_loading] = getImage(getCodeBase(),"cards/" + (current_card_loading+1) + ".gif");
               if(card_images[current_card_loading] == null){
                    System.out.println("Null card... ["+current_card_loading+"]");
               else{
                    t.addImage(card_images[current_card_loading],0);
               try{
                    t.waitForID(0);
               catch(InterruptedException e){
                    System.err.println("Interrupted waiting for images..>");
               //lets show our new status.
               repaint();
          //create the deck object now
          deck = new Deck(this,card_images);     //Create a new deck object.
          card_width = deck.getCard(0).getImage().getWidth(this);
          bHit.addActionListener(this);
          bStay.addActionListener(this);
          bRestart.addActionListener(this);
          bHit.setEnabled(false);
          bStay.setEnabled(false);
          width = getSize().width;
          height = getSize().height;
          this.add(bHit);
          this.add(bStay);
          this.add(bRestart);
          player_hand = new Hand();     //Create the hands...
          dealer_hand = new Hand();
          //make sure that the buttons appear properly.
          this.validate();
          message = "";
          cards_loaded = true;
          System.out.println("End of thread...");
          repaint();
----jGRASP exec: javac -g X:\NETPROG\Assignment2\Blackjack.java
Blackjack.java:7: Blackjack is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
public class Blackjack extends JFrame /*Applet*/ implements ActionListener,MouseListener/*,Runnable*/{
^
Blackjack.java:53: cannot find symbol
symbol : constructor Thread(Blackjack)
location: class java.lang.Thread
     Thread card_loader = new Thread(this);
^
Blackjack.java:209: cannot find symbol
symbol : method getCodeBase()
location: class Blackjack
               card_images[current_card_loading] = getImage(getCodeBase(),"cards/" + (current_card_loading+1) + ".gif");
^
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
import java.awt.*;
import javax.swing.JFrame;
import java.net.*;
import java.io.*;
class Deck {
     Card[] cards = new Card[52];
     int currCard;
     public Deck(/*Blackjack myApplet*/Blackjack myFrame,Image[] card_images) {
          // These are the (initial) values of all the cards
          int[] values = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
               11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
               11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
               11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10};
          // Make all the cards, getting the images individually
          for (int i=0; i<52; i++) {
               cards[i] = new Card(card_images, values[i]);
          // Shuffle the cards.
          shuffleCards();
     public void shuffleCards(){
          Card temp;
          //loop through each card in the deck and swap it with some random card.
          for (int i=0; i<52; i++) {
               int rand = (int)(Math.random()*52);
               temp = cards[51-i];//take the current card...
               cards[51-i] = cards[rand];//and swap it with some random card...
               cards[rand] = temp;
          //now, reset the currentCard to deal...
          currCard = 0;
     public Card dealCard() {
          Card card = cards[currCard];
          currCard++;
          return card;
     public Card getCard(int i) {
          return cards[i];
----jGRASP exec: javac -g X:\NETPROG\Assignment2\Deck.java
Blackjack.java:6: Blackjack is not abstract and does not override abstract method mouseExited(java.awt.event.MouseEvent) in java.awt.event.MouseListener
public class Blackjack extends JFrame implements ActionListener,MouseListener{
^
Blackjack.java:45: cannot find symbol
symbol : constructor Thread(Blackjack)
location: class java.lang.Thread
     Thread card_loader = new Thread(this);
^
Blackjack.java:201: cannot find symbol
symbol : method getCodeBase()
location: class Blackjack
               card_images[current_card_loading] = getImage(getCodeBase(),"cards/" + (current_card_loading+1) + ".gif");
^
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

Similar Messages

  • Converting an Applet into an Application

    I think I understand the basics of converting an Applet into an Application but Iam unsure on how you would go about passing the parameters that are normally stored in the HTML tag into the application.

    Basically you'll need to provide your own getParameter
    method. It's easy with a java.util.HashTable -- the
    parameter name as the key.that means that i would have to go back and change the old code, correct?

  • Help with converting an applet into an application

    Here is a set of code which can work perfectly fine as an applet. But I have problem converting it into an application. Any help? I get some null pointer exception. Thanks alot.
    //File Name: Radar.java
    //Author: Saad Ayub
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Flash extends Thread{
    private DrawA dA;
    private int x;
    private int xCor[];
    private int yCor[];
    private int i;
    private int dir;
    private Image im;
    private Graphics buff;
    public Flash(DrawA dA, Image im, Graphics buff){
    this.dA = dA;
    this.im = im;
    this.buff = buff;
    xCor = new int[451];
    yCor = new int[451];
    dir = 10;
    }//end of Flash constructor
    public void run(){
    for(x = 75, i = 0; x <= 525; x++, i++){
    xCor[i] = x - 300;
    for(i = 0; i <= 450; i++){
    yCor[i] = (int)Math.sqrt(62500 - (xCor[i] * xCor));
    yCor[i] = 300 - yCor[i];
    for(x = 0; x <= 450; x++){
    xCor[x]+=300;
    i = 0;
    while(true){
    try{
    Thread.sleep(35);
    catch(Exception e){}
    dA.repaint();
    i += dir;
    if(i < 0 || i > 450){
    dir = -dir;
    i += dir;
    }//end of if
    }//end of while
    }//end of run
    public void draw(Graphics g){
    int green = 255;
    buff.setColor(Color.black);
    buff.fillRect(0, 0, 600, 330);
    buff.setColor(new Color(0, 70, 0));
    buff.fillArc(50, 50, 500, 500, 25, 130);
    buff.setColor(Color.green);
    if(i > 450)
    return;
    if(xCor[i] != 0 && yCor[i] != 0)
    buff.drawLine(xCor[i], yCor[i], 300, 300);
    if(dir > 0){
    for(int j = i; j > (i - 100); j--){
    if(j >= 0 && j <= 450){
    green -= 2;
    buff.setColor(new Color(0, green, 0));
    buff.drawLine(xCor[j], yCor[j], 300, 300);
    }//end of if
    }//end of for
    }//end of if
    else{
    for(int j = i; j < (i + 100); j++){
    if(j >= 0 && j <= 450){
    green -= 2;
    buff.setColor(new Color(0, green, 0));
    buff.drawLine(xCor[j], yCor[j], 300, 300);
    }// end of if
    }//end of for
    }//end of else
    buff.setColor(Color.green);
    buff.drawArc(112, 112, 375, 375, 25, 130);
    buff.drawArc(174, 174, 250, 250, 25, 130);
    buff.drawArc(238, 238, 125, 125, 25, 130);
    buff.drawLine(300, 300, 300, 50);
    g.drawImage(im, 0, 0, null);
    }//end of draw
    }//end of flash class
    class DrawA extends Panel{
    private Flash fl;
    private Image im;
    private Graphics buff;
    public DrawA(Image im){
    this.im = im;
    buff = im.getGraphics();
    fl = new Flash(this, im, buff);
    fl.start();
    // setBackground(Color.black);
    public void paint(Graphics g){
    fl.draw(g);
    public void update(Graphics g){
    paint(g);
    public class Radar extends Applet{
    public DrawA dA;
    private JLabel display;
    public Radar()
    display = new JLabel("display");
    public void init(){
    dA = new DrawA(createImage(600, 330));
    setLayout(new BorderLayout());
    add(dA, BorderLayout.CENTER);
    add(display, BorderLayout.EAST);
    public void stop(){
    destroy();
    Edited by: bozovilla on Oct 20, 2008 8:32 AM

    Start out by letting this thread die out...
    and repost saying that you forgot to use code tags and describe sufficiently what your problem is--things like the actual error message and where it happens.

  • 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.

  • How can I convert my animation into a working movie clip that can be used with a new scene?

    Hello all,
    First and foremost, I AM A TOTAL FLASH NOOB. I want to preface this and make it incredibly clear how new this all is to me. I LITERALLY started using flash this morning; that is precisely how new I am.
    With that being said I am going to do my best to explain what I'd like to do.
    I have created an animation of a spider moving its legs back and forth. I want to be able to combine all of the layers into 1 simple animation that can be imported into new flash scenes with the animation exactly how it stands. I have figured out how to convert the whole animation into a symbol AND I have figured out how to import the movie clip from the library. However, herein lies my problem. When I open a new flash scene and import my animation, I play it and it does nothing at all. It's just the static image of the spider I created with no movement.
    I've spent the last couple hours trying to figure out (and doing my own research) what I have done or didn't do to get to this point. I'd be willing to bet I am just going about the entire process incorrectly and I'm simple overlooking a basic facet of the program.
    Any insight to fix my ignorance is greatly appreciated.
    (P.S. Hell, I don't even know if I am using the correct terminology so for all I know I am confusing every person who has taken the time to look at my question. If I am using incorrect terminology please correct me to avoid future hang ups. Thank you.)

    Ned! This totally worked! Thank you! I knew there was a tiny piece of this whole thing that was preventing me from making everything work. Unfortunately as my luck would have it, although I have the movieclip working the spritesheet converter I'm using now no longer recognizes the movie clip. The converter says there are 7 frames in the animation, but doesn't display any working sprites. Just a blank sheet. Frustrating to say the least.
    I'm just going to throw everything out on the table here:
    This is the video tutorial i'm using to convert my animation into a spritesheet. I've done the steps exactly as directly up until the point I actually click "Begin Conversion." When begin conversion is selected, it shows the movieclip exists on the bottom left underneath "list of movieclips" but doesn't actually show any individual sprites.
    Here's the simple sprite converter I am using.
    The irony of this whole situation is that you have successfully helped me make a working movieclip (which was the important piece), but the converter no longer recognizes it. Whereas before, it would at least show the image on the 1 frame of animation it had.
    If you wanted to to take a stab at it and see if you can successfully get it to work I'd be appreciative. If not, I totally understand as you have already been incredibly helpful and have my eternal gratitude for getting me this far. These animation programs can be quite overwhelming when they so vastly differ from one another. Don't even get me started no Anime' Studio Pro.

  • Converting appleworks document into jpeg - image quality

    I am createing a project with some students where we have video taped book reviews. They have then created awards for these books using Applework 6.
    I have had the kids save the certificates as jpeg2000 files using the best quality.
    When I drag and drop the file into my iMoive - the image quality is really fuzzy.
    1. Do I need to resize this image and if so what is the optimal size for iMovie?
    2. Can I do this easily using iphoto or do I need a graphic converter?
    Hope someone can help. Thanks Michael H.

    iMovie is a DV editing app and anything imported to it must either already be .dv or it will be converted to .dv file format.
    Your still image file will be turned into 30 frame per second "video" and also resized to NTSC dimensions.
    QuickTime Pro can open image formats and can be used to make "movies". These are not dimensions limited and look just fine on a computer. Since the image is not rendered as "video" a single image file can stay one the screen as long as you like. Hundreds of times smaller in file size, too. Some of mine:
    http://homepage.mac.com/kkirkster/03war/
    http://homepage.mac.com/kkirkster/RedneckTexasXmas/index.html
    http://homepage.mac.com/kkirkster/California/index.html

  • Converting an Image into a Button

    Hello all,
    I'm a very new user to Adobe Flash, and am trying to figure out some of the small things. I was wondering if anyone could help me out with how to convert an image into a button (with a URL).
    Thank you!
    Dave

    Let's say you created a button symbol. The first thing you need to do to make it useful code-wise is to assign it a unique instance name.  So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"
    In AS3, to make a button work with code, you need to add an event listener and event hamdler function for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:
    btn1.addEventListener(MouseEvent.CLICK, btn1Click);
    The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:
    function btn1Click(evt:MouseEvent):void {
       var url:String = "http://www.awebsite.com/awebpage.html";
       var req:URLRequest = new URLRequest(url);
       navigateToURL(req);

  • IDCS3 - Paste image into new frame with same cropping offsets?

    Anyone know if there's a better way do to this?<br />It used to work in CS2, and (I know this comment won't be popular, but since half the studio I'm trying to convert brings up this point, I'll pass it along <G>), it's always worked in Quark. <G><br />http://indesignsecrets.com/paste-image-into-new-frame-with-same-cropping-offsets.php<br />Be nice to get this to work without having to jump through hoops.<br />(And please, please don't tell me I need to update to CS4 to get this basic functionality BACK).<br />k.

    Thanks, Rob. Unfortunately, I got a new error with the latest script you posted (sorry--not trying to be a pest!!). It says,
    Apple Script Error!
    Error Number: -2753
    Error String: The variable myRend is not defined.
    (One thing that's different is I'm working on a different machine than I was the first day I posted about this, but I'm using the exact same version of InDesign. Would this make a difference? I forgot to copy the original script file from the other computer before coming to work today... If I need to do that, I can.)
    Thanks for your continued help!

  • Is there any way to convert the ImportObject into an image file ?

    I have converted a FM document into MIF file format. FM has a grapic imported by copying into the document. In the MIF file I can see the image like the following,
    <ImportObject
      <Unique 1001019>
      <Pen 15>
      <Fill 7>
      <PenWidth  1.0 pt>
    =TIFF
    &%v
    &II*\x00080000001000FE000400010000000000000000010300010000006009000001010300010000…..
    Is there any way to convert the ImportObject inside the mif file into an image file ?

    Error 7103,
    Regarding Note A and Note B... The Downsample dropdowns list three variations of Downsampling TO, each corresponding to a different downsampling method. When you select one of the Downsampling TO options, then the pixels per inch box allow you to specify the dpi of the downsampled image, the one after the downsampling.
    When you select Off, which means do NOT downsample, then the pixels per inch box is meaningless. Maybe it would be a nice interface feature to disable it, but that is another issue. In any event, OFF ignores any value in pixels per inch.
    Whenever you import an image into your publishing program (FrameMaker, InDesign, or whatever) and scale it, one can think of the scaled image as having a physical dpi, the number of pixels per physical inch on the "paper." When you specify downsampling in Distiller, the number you specify is most likely less than the physical dpi of the image in the document. It is probably meaningless to specify a number that is larger. I am guessing (and this is a guess) that Distiller does not UPsample images. I have never tested it.
    I use 1200 for image recovery.
    I assume you are talking about recoverying an image embedded in (copied into) the publishing document. I believe it is sufficient simply to turn downsampling off to create a PDF with the image at the resolution as embedded in the document.
    No, one of the settings is to Determine Automatically, which uses the resolution of the image IN the PDF.
    Where is that found?
    It is NOT in Distiller. It is in Acrobat Professional. (It may or may not be in Acrobat Standard or Acrobat Reader; I do not have them, so do not know.)
    The original poster wanted to recover an image copied into a Frame document file. My method is to create a PDF using a Distiller joboption with ALL downsampling and ALL compression OFF. Presumably the image is put into the PDF with all the pixels it has in the Frame file.
    THEN in Acrobat PROFESSIONAL, export the image with the setting Determine Automatically. I am presuming (never tested it) this exports ALL the pixels that the image has in the PDF file.
    Van

  • Keylistener breaks when implementing applet into application

    I am currently trying to imbed my "Game" into an application to make a game menu for it. However, when
    i try and do this the game loads fine but my keylistener doesnt work.
    I am using the code.
    import java.awt.*;
    import java.applet.*;
    public class RunApplets_BROKEN
    public static void main (String [] args)
    Applet myApplet = new Bomberman_Version_Aplha_EDITABLE (); // define applet of interest
    Frame myFrame = new Frame ("Applet Holder"); // create frame with title
    // Call applet's init method
    myApplet.init ();
    // add applet to the frame
    myFrame.add (myApplet, BorderLayout.CENTER);
    myFrame.setSize (500, 600);
    myFrame.setVisible (true); // usual step to make frame visible
    } // end main
    } // end class
    I know this is bad programming and i am trying to keep it simple, however when i do this to my other program it works fine. So i dont understand. Could anyone please help?

    Intentional multi-post
    [http://forums.sun.com/thread.jspa?threadID=5360722]
    You were given two answers yesterday. Don't start a new thread because you didn't like them, that just wastes peoples time.

  • Can I convert a collection into a collection set

    Hi,
    Is it possible to convert a collection into a collection set.  I have two scenarios I am trying to deal with right now.
    1.  I have two separate collections.  I would like to move one collection into another, such that collection A contains what was in collection A plus the collection B i move into it?
    2. I have photos I want to make into a collection and place into another collection.  The dialog box only allows you to select current collection sets.
    To do this do I really need to basically start over and create a new collection set and new collections in order to move them into the collection set?
    Thanks,
    Scott

    Not possible. Why don't you do this?
    Library-Grid View [ G ]
    Click on Collection B
    Cmd/CTRL A to select all
    Drag (by grabbing the thumbnail - not the frame) into Collection A.

  • Move a movie into a frame before playing?

    Am I correct that I can't move a movie into a frame, with a transition, and then have it start playing? (KN ver. 6) I tried to do it using a "move" action, but it always appears in the frame. Unlike a normal pic, it doesn't move in.
    And, as I need to use "start movie" as the "build in" transition, and I'm only allowed one "build in" transition, I can't first make it move in with a move transition, then make it start.
    I'll suggest some more flexibility to Apple.

    Hi
    Check out Videora Converter from Red Kawa. Works for me.

  • Converting SPool information into HTML Format

    Hi Friends,
    How to Converting SPool information into HTML Format
    and send this HTML INFORMATION INTO MAIL..
    can anyone send program for this issue pls.
    it is an urgent issue
    regards,

    Hi Rich,
    once again thanks for your kindly reply.
    but i am developing below Code.. that HTMAL AATCHMENTS ARE NOT COMING IN MAIL.
    PLS can you you verify the below code.
                           DATA DECLARATIONS                             *
    DATA: I_LIST   LIKE ABAPLIST OCCURS 0  WITH HEADER LINE,
          VARIANT  LIKE RSVAR-VARIANT,
          DOC_CHNG  LIKE SODOCCHGI1,
           RECLIST LIKE SOMLRECI1  OCCURS 5  WITH HEADER LINE,
    data:  spoolid    type tsp01-rqident.
    DATA IT_MAIL LIKE TSP01 OCCURS 0 WITH HEADER LINE.
    data  report_html like W3HTML  OCCURS 0 WITH HEADER LINE.
    DATA: G_ICONS(32) OCCURS 10 WITH HEADER LINE.
    DATA LISTOBJECT LIKE ABAPLIST OCCURS 0 WITH HEADER LINE.
    DATA  sent_to_all like sonv-flag.
    data : RECEIVER(30),
          spoolid    type tsp01-rqident,
           it_buffer like SOLI occurs 10 with header line.
    data: list type table of  abaplist with header line.
    data: htmllines type table of w3html with header line.
    data: maildata   like sodocchgi1.
    data: mailtxt    like solisti1 occurs 10 with header line.
    data: mailrec    like somlrec90 occurs 0  with header line.
                           TABLE DECLARATIONS                            *
    TABLES : TSP01.
                               SELECTION-SCREEN                          *
    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN: SKIP.
    PARAMETERS : RQ2NAME LIKE TSP01-RQ2NAME .
                RQIDENT like TSP01-RQIDENT.
    SELECT-OPTIONS :  S_RECVR FOR RECEIVER  NO INTERVALS.
    SELECTION-SCREEN: SKIP.
    SELECTION-SCREEN: END OF BLOCK B1.
                               START-OF-SELECTION                        *
    START-OF-SELECTION.
    PERFORM SEND_TO_SPOOL.
      PERFORM GET_SPOOL_ID.
      loop at it_mail.
        PERFORM CONVERT_SPOOL_TO_PDF.
        PERFORM SEND_MAIL.
      endloop.
    Save the list
      call function 'SAVE_LIST'
           tables
                listobject         = list
           exceptions
                list_index_invalid = 1
                others             = 2.
    *&      Form  GET_SPOOL_ID
          Getting the Latest Spool Request Number
    FORM GET_SPOOL_ID.
      SELECT *
            FROM TSP01 INTO TABLE  IT_MAIL
           and   RQIDENT    = RQIDENT.
              WHERE  RQ2NAME   =  RQ2NAME .
    ENDFORM.                    " GET_SPOOL_ID
    *&      Form  CONVERT_SPOOL_TO_PDF
          Converting the Spool to PDF Document
    FORM CONVERT_SPOOL_TO_PDF.
    *--Assigning the Spool number
    WRITE :/ IT_MAIL-RQIDENT.
    spoolid = IT_MAIL-RQIDENT.
    *--Converting the Spool to PDF
    CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
      EXPORTING
        RQIDENT                    =  spoolid
      FIRST_LINE                 = 1
      LAST_LINE                  =
      TABLES
        BUFFER                     = it_buffer
    EXCEPTIONS
      NO_SUCH_JOB                = 1
      NOT_ABAP_LIST              = 2
      JOB_CONTAINS_NO_DATA       = 3
      SELECTION_EMPTY            = 4
      NO_PERMISSION              = 5
      CAN_NOT_ACCESS             = 6
      READ_ERROR                 = 7
      OTHERS                     = 8
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LISTOBJECT = IT_BUFFER.
    CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
    EXPORTING
      REPORT_NAME         =
       TEMPLATE_NAME       = 'WEBREPORTING_REPORT'
      TABLES
        HTML                = report_html
        LISTOBJECT          = LISTOBJECT
       LISTICONS           = G_ICONS.
    ENDFORM.                    " CONVERT_SPOOL_TO_PDF
    FORM SEND_MAIL.
    call function 'WWW_LIST_TO_HTML'
           tables
                html = htmllines.
    maildata-obj_name = 'TEST'.
      maildata-obj_descr = 'Test Subject'.
      loop at htmllines.
        mailtxt = htmllines.
        append mailtxt.
      endloop.
    LOOP AT S_RECVR.
    reclist-receiver = S_RECVR-LOW.
    reclist-rec_type = 'U'.
    append reclist.
    call function 'SO_NEW_DOCUMENT_SEND_API1'
           exporting
                document_data              = maildata
                document_type              = 'HTM'
                put_in_outbox              = 'X'
           tables
                object_header              = report_html "mailtxt
                object_content             = mailtxt
                receivers                  = reclist "mailrec
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
      if sy-subrc = 0.
    write 'mail sent'.
      endif.
    ENDLOOP.
    regards,
    venu.

  • Need to convert a long into a string, please

    hi there
    i need to convert a long into a string. can i just cast it like this:
    (String)longNumber = some function that returns a long;

    Why not just use Long.toString()? If you start with a long value, you can create a Long object and get it's value as a String.

  • Report for converting the documents into the PDF format.

    Hello Experts,
    I need to know if any report/ T-code is available in SAP to convert the files into  PDF format.
    We are processsong these PDF's then into IXOS system.
    Regards,
    Anna.

    Hello ,
    You may check with the below programs:
    Program name                   Report title
    RSTXCPDF                       Routines for Converting OTF Format to PDF Format
    RSTXPDF2                       Administration/Upload of type 1 and TrueType font files
    RSTXPDF3                       Customizing for OTF-PDF Conversion
    RSTXPDF4                       Help Report from CONVERT_OTFSPOOLJOB_2_PDF
    RSTXPDF5                       Help Report from CONVERT_ABAPSPOOLJOB_2_PDF
    RSTXPDFT                       Test report for PDF conversion - converting standard texts to PDF
    RSTXPDFT2
    RSTXPDFT3                      Test
    RSTXPDFT4                      Convert SAPscript (OTF) or ABAP Lists Spool Job by PDF
    RSTXPDFT5                      Test: GUI Download of Spool Request
    Regards
    Ramesh Ch

Maybe you are looking for