Please I'm new to Java programming. I'm writing an application which has to bring a welcome message to the user and will later bring out buttons to enable the user to choose what next to do. Please what should I do to achieve what I needed in the application?
I succeeded in making the application to animate welcome texts for the user, but when I created a button, it didn't appear after the welcome messages.
The following code fragment is an example of how I tried to achieve the aim but failed.
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()}}
Please I need urgent intervention which I will so muchly appreciate. If my question need further explanation, I will be glad to explain further.
Thanks a lot as you comply.