Showing posts from December, 2020Show all

9) Text Field enable and disable using buttons

source code name: btenabledisable.java  import java.awt.*;     import java.awt.event.*;  class btenabledisable extends Frame implements ActionListener { TextField t1;  public btenabledisable() {   FlowLayout fl=new FlowLayout(1,20,10); setLayout(fl);       t1=new TextField(25); Button b1=new Button("enable&q…

Read more

4) Display Circle any where on Screen using Mouse Event

source code name: MouseDemo3.java      import java.awt.*;      import java.awt.event.*;  class MouseDemo3 extends Frame implements MouseListener { int x,y;  public MouseDemo3() {   addMouseListener(this); }   public void mousePressed(MouseEvent me) { x=me.getX(); y=me.getY(); repaint(); } public void mouseReleased(Mou…

Read more

3) Display Mouse Coordinates on screen using Mouse Event

source code name: MouseDemo2.java      import java.awt.*;      import java.awt.event.*;  class MouseDemo2 extends Frame implements MouseListener { String str="wel come"; int x,y;  public MouseDemo2() {   addMouseListener(this); }   public void mousePressed(MouseEvent me) { System.out.println("mouse is …

Read more

2) Mouse operations messages using Mouse Event

source code name: MouseDemo1.java     import java.awt.*;      import java.awt.event.*;  class MouseDemo1 extends Frame implements MouseListener {  public MouseDemo1() {  addMouseListener(this); }   public void mousePressed(MouseEvent me) { System.out.println("mouse is Pressed"); } public void mouseReleased…

Read more

3) Discount program while purchasing items.

source code name: discount.C void main() { int qty,rt,amt,amtpaid; int dis=0; clrscr(); printf(" enter quantity and rate of items: \n"); scanf("%d%d",&qty,&rt); amt=qty*rt; if(amt>=1000) dis=amt*0.1; else printf("\n sorry no discount , purchase some items "); amtpaid=amt-dis; …

Read more

4) Find maximum number from 3 numbers.

source name: max3.C  #include<stdio.h> void main() { int a,b,c; clrscr(); printf(" enter any three numbers:  \n "); scanf("%d%d%d", &a, &b, &c); if(a>b &&  a>c) printf(" \n maximum is A number=%d ",a); if(b>c) printf(" \n maximum is B number=%d &quo…

Read more

7) Random color to rectangle using ActionEvent

source code : randomcolor.java     import java.awt.*;     import java.awt.event.*;  class randomcolor extends Frame {  Color col=Color.green;    public randomcolor(){  setLayout(null);      Button b1=new Button("randomcolor");//create button      b1.setBounds(100,80,100, 40);  add(b1);//adding button on fra…

Read more

6) Simple calculator window program using ActionEvent.

source code: calc.java import java.awt.*; import java.awt.event.*; class calc extends Frame implements ActionListener { TextField t1,t2, t3; public calc() { FlowLayout fl=new FlowLayout(); setLayout(fl); Label l1=new Label("enter a no:"); Label l2=new Label("enter b no"); Label l3=new Label("…

Read more

4) Login window program using ActionEvent

source code: login.java import java.awt.*; import java.awt.event.*; class login extends Frame implements ActionListener { TextField t1,t2; public login() { FlowLayout fl=new FlowLayout(); setLayout(fl); Label l1=new Label("user name"); Label l2=new Label("password");  t1=new TextField(15);  t2=new…

Read more

4) Copy contains one file to another file.

import java.io.*; class filedemo1 { public static void main(String as[]) { System.out.println("file related program"); int n; try { FileInputStream fis=new FileInputStream("input.txt"); FileOutputStream fos=new FileOutputStream("newdata.txt");   int c;       …

Read more

3) Write a program that display Directory or File .

The  program should accept command line argument,  if  it file then File name display and if it Directory then contains of directory  is displays.   import java.io.*; public class FileDemo {      public static void main(String as[])     {         File f=null;       try { f=new File(as[0]); System…

Read more