Button on welcome message for user

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SWEETZYING
    New Member
    • Oct 2011
    • 1

    Button on welcome message for user

    Please I'm new to programming in Java Technology Standard Edition (SE). I'm working on a project and need some help.

    I created an application with a welcome message to the user. After animating the texts, I want it to bring out a button for the user to press on but it couldn't work. Please what will I do?

    Please if this question is not well understood, I'll need a response to let me know so that I will repeat it in a more comprehensive way.

    Code:
    import java.awt.*;
    import java.applet.Applet;
    
    enum TextsContainer
    {
      FIRST1_DISPLAY("MY FIRST NAME IS"),  FIRST2_DISPLAY("MY SECOND NAME IS");
    
      private final String context;  
    
      private TextsContainer(String context)
      {
        this.context=context;
      }   
    
      public String getContext()
      {
        return context;
      }
    }
    
    class ProcessTextsContainer
    {  
      private TextsContainer textContainer;   
      public ProcessTextsContainer(TextsContainer textContainer)
      {
        this.textContainer=textContainer;
      }   
      public TextsContainer getTextContainer()
      {
        return textContainer;
      }
    }
    
    public class ExecuteTexts extends Applet implements Runnable
    {   
      Thread thread=new Thread(this);  
      Font font1=new Font("Courier",Font.BOLD+Font.ITALIC,50);
      public ProcessTextsContainer paintText1_1=new ProcessTextsContainer(TextsContainer.FIRST1_DISPLAY);
      public ProcessTextsContainer paintText1_2=new ProcessTextsContainer(TextsContainer.FIRST2_DISPLAY);
      public String currentText1_1=paintText1_1.getTextContainer().getContext();
      public String currentText1_2=paintText1_2.getTextContainer().getContext();
    
      public void start()
      {
        if(thread==null)
        {
          thread=new Thread(this);
        }
      }   
      public void stop()
      {
        if(thread!=null)
        {
          thread.stop();
        }
      }   
      public void run(){}   
      public void pause(int duration)
      {
        try
        {
          thread.sleep(duration);
        }
        catch(InterruptedException e)
        {
        }
      }   
      public void paint(Graphics graphics)
      { 
        graphics.setColor(Color.getHSBColor((float)50.0,(float)30.3,(float)5.30));
        graphics.setFont(font1);graphics.drawString(currentText1_1.toString(),10,100);graphics.setColor(Color.BLUE);
        graphics.setFont(font2);pause(100);graphics.clearRect(10,70,481,330);
        graphics.setFont(font1);graphics.setColor(Color.ORANGE);
        graphics.drawString(currentText1_2,10,100);
        graphics.setFont(font2);
        graphics.setColor(Color.BLUE);
        graphics.clearRect(10,70,602,31);
        graphics.clearRect(72,127,858,79);
      }   
    
      public static void main(String[]args)
      { 
        Applet applet=new ExecuteTexts();
        Button button=new Button("Ok");
        Frame frame=new Frame("TESTING TEXTS");
        frame.add(applet);
        frame.add(button);
        frame.show()
      }
    }
    Thanks a lot as you comply.
    Attached Files
    Last edited by Frinavale; Oct 14 '11, 04:21 PM. Reason: Formatted code so that it is more legible. Please put your statements on separate lines and include indenting for code because it is very very difficult to read code all on one line.
Working...