Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label Applet. Show all posts
Showing posts with label Applet. Show all posts

Wednesday, 5 September 2012

Java Applet code to Create a drop down list named textAlignment



//The Java Abstract Windowing Toolkit
import java.awt.*;

public class DropDownListFont extends java.applet.Applet {
//Create a drop down list named textAlignment
Choice textAlignment = new Choice();

public void init() {
//Add 4 different options to it:
textAlignment.add("Left");
textAlignment.add("Center");
textAlignment.add("Right");
textAlignment.add("Random");
//Then add the drop down list to the screen
add(textAlignment);
}
}

Thursday, 30 August 2012

Java Applet code to Create a checkbox group named age



//The Java Abstract Windowing Toolkit
import java.awt.*;

public class RadioButtonAge extends java.applet.Applet {
//Create a checkbox group named age (these hold other
//Checkboxes making them radio buttons or option boxes
    CheckboxGroup age = new CheckboxGroup();
//Create 4 checkboxes in the age group, the third one's
//Starting value is true
    Checkbox chkUnder10 = new Checkbox("Under 10 years old", false, age);
    Checkbox chk10to15 = new Checkbox("10 to 14 years old", false, age);
    Checkbox chk15to20 = new Checkbox("15 to 19 years old", true, age);
    Checkbox chkOver20 = new Checkbox("Over 20 years old", false, age);


    public void init() {
//Add them all to the screen
        add(chkUnder10);
        add(chk10to15);
        add(chk15to20);
        add(chkOver20);
    }
}

Java Applet code to Create a text area named comments with the text



//The Java Abstract Windowing Toolkit
import java.awt.*;

public class TextAreaComments extends java.applet.Applet {
//Create a text area named comments with the text:
//This is on line 1
//This is on line 2
//And make it 3 characters tall and 20 characters wide
    TextArea comments = new TextArea("This is on line 1\nThis is on line 2", 3,20);

    public void init() {
//Add it to the screen
        add(comments);
    }
}

Java applet code to Create a text field named TextFieldName



//The Java Abstract Windowing Toolkit
import java.awt.*;

public class TextFieldName extends java.applet.Applet {
//Create a text field named TextFieldName with the
//text Codinglovers in it and make it big enough to hold 10 characters
    TextField TextFieldName = new TextField("Codinglovers", 10);

    public void init() {
//Add it to the screen
        add(TextFieldName);
    }
}

Java applet code to Create a label named eMailLable with the caption E-mail address


//The Java Abstract Windowing Toolkit
import java.awt.*;

public class EmailLabel extends java.applet.Applet {
//Create a label named eMailLable with the caption E-mail address:
    Label eMailLabel = new Label("E-mail address: ");

    public void init() {
//Add the label to the screen
        add(eMailLabel);
    }
}

Java Applet Code to create button


//The Java Abstract Windowing Toolkit
import java.awt.*;

public class SimpleButton extends java.applet.Applet {
//Create a button named helloButton with the caption Hello World!
    Button helloButton = new Button("Hello World!");

    public void init() {
//Add the button to the screen
        add(helloButton);
    }
}