Advanced Java Programs
Advanced Java Programs
1. Use Java AWT package to create a frame (By making a Frame object
(Association)) and add these controls -> a) Label b) Button c) TextField
package com.company;
import java.awt.*;
frame.setSize(400,300);
frame.setTitle("AWT Example (By Association)");
frame.setLayout(null);
frame.setVisible(true);
}
}
OUTPUT
2. Use Java AWT package to create a frame (By extending the Frame class
(Inheritance)) and add these controls -> a) Label b) Button c) TextField
package com.company;
import java.awt.*;
setSize(400,300);
setTitle("Awt Example (By Inheritance)");
setLayout(null);
setVisible(true);
}
}
OUTPUT
3. Draw a Line, a Rectangle, an Oval using java AWT package. Colour them
with your choice of colours. Also, write a line of text and change its font, size,
and style.
package com.company;
import java.awt.*;
setSize(600,600);
setTitle("Awt Example (By inheritance)");
setLayout(null);
setVisible(true);
}
g.setColor(Color.RED);
g.drawOval(110,70,30,80);
//g.setColor(Color.MAGENTA);
Color myColor = new Color(100,255,100);
g.setColor(myColor);
g.fillOval(90,200,80,80);
OUTPUT
4. Create a java frame using java AWT package and add these controls->
a) Radio Buttons b) Checkboxes c) List d) Choice Menu e) Text Area
package com.company;
import java.awt.*;
public class awt4
{
awt4(){
Frame f= new Frame("AWT Controls Example");
f.setSize(600,600);
f.setLayout(null);
f.setVisible(true);
}
OUTPUT