|
-
Please! can anyone help me on this, Please!
Hi!,
Please! anyone help me on this and If anyone read this please help me on this and I don't know what is the problem on this and here is an sample output. Please!, help me on this.
Sample Output:
Enter Month Code: 1
January
Enter Month Code: a
Letter is Not Accepted!!!
Here is the Java Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class MonthApp extends Applet implements ActionListener
{
Label lmonth=new Label("Enter Month Code:");
TextField tmonth=new TextField(3);
Font large=new Font("Tahoma",Font.BOLD,15);
Button displaymonth=new Button("Display Month!!!");
public void init()
{
add(lmonth);
add(tmonth);
add(displaymonth);
displaymonth.addActionListener(this);
}
public void actionPerformed(ActionEvent AlcioAbaquita)
{
int monthcode=Integer.parseInt(tmonth.getText());
Label month=new Label("");
Label text=new Label("");
String displaybutton=displaymonth.getLabel();
switch (monthcode)
{
case 1:
month.setText("January");
month.setFont(large);
add(month);
break;
case 2:
month.setText("February");
month.setFont(large);
add(month);
break;
case 3:
month.setText("March");
month.setFont(large);
add(month);
break;
case 4:
month.setText("April");
month.setFont(large);
add(month);
break;
case 5:
month.setText("May");
month.setFont(large);
add(month);
break;
case 6:
month.setText("June");
month.setFont(large);
add(month);
break;
case 7:
month.setText("July");
month.setFont(large);
add(month);
break;
case 8:
month.setText("August");
month.setFont(large);
add(month);
break;
case 9:
month.setText("September");
month.setFont(large);
add(month);
break;
case 10:
month.setText("October");
month.setFont(large);
add(month);
break;
case 11:
month.setText("November");
month.setFont(large);
add(month);
break;
case 12:
month.setText("December");
month.setFont(large);
add(month);
break;
default:
month.setText("Invalid Month Code!!!");
month.setFont(large);
add(month);
text.setText("Letter is Not Accepted!!!");
text.setFont(large);
add(text);
}
validate();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks