Skip to main content

Posts

checkbox example in java

                               checkbox example import java.applet.*; import java.awt.*; import java.awt.event.*; /*             <applet code="CheckDemo" height=200 width=200>             </applet> */ public class CheckDemo extends Applet implements ItemListener {             Label lbl;             public void init() {                         Checkbox ch1=new Checkbox("Red");                         add(ch1);   ...

Checkbox example in java

                Checkbox example in awt import java.applet.*; import java.awt.*; import java.awt.event.*; /*             <applet code="CheckDemo" height=200 width=200>             </applet> */ public class CheckDemo extends Applet implements ItemListener {             Label lbl;             public void init() {                         Checkbox ch1=new Checkbox("Red");                         add(ch1);           ...

checkbox

control and method of checkbox in awt Checkbox class:             This class is used to create the check box control. This will create a small box and label in front of it. If we click in the box the check mark will appear in it. The Constructors of the Checkbox control: a) Checkbox()                         It will create the Checkbox with no Label information with it. b) Checkbox(String s)                         It will create the Checkbox with string s containing the information to be displayed in the label in front of the check box c) Checkbox(String s,boolean state,CheckboxGroup cg)                 ...

button class example in java

                     button class example import java.awt.*; import java.applet.*; import java.awt.event.*; /* <applet code="ButtonDemo3" height=200 width=200> </applet> */ public class ButtonDemo3 extends Applet implements ActionListener {             Button b1,b2;             Label msg; public void init()             {                         msg=new Label("                                           ...

Exception handling user define in java

         user define Exception handling import java.lang.Exception;  import java.lang.*; import java.lang.Exception;  import java.io.DataInputStream; class MyException extends Exception { MyException(String message) { super(message); } } class userdef { public static void main(String a[]) { int age; DataInputStream ds=new DataInputStream(System.in);  try { System.out.println("Enter the age (above 15 abd below 25) :"); age=Integer.parseInt(ds. readLine()); if(age<15 || age> 25) { throw new MyException("Number not in range"); } System.out.println(" the number is :" +age); } catch(MyException e) { System.out.println("Caught MyException"); System.out.println(e. getMessage()); } catch(Exception e){ System.out.println(e); } } }