JAVA AWT Frame Via Inheritance #4(With Panel,setForeground)

1,277 views · Published 30 October 2017 · 10:35 · Indexed 6 November 2026

Channel: AndroJavaTech4U · 2017 · Science & Technology

Watch on YouTube

In this video tutorial you can understand the concept of  how to creating awt frame via inheritance and also explain the use of Panel and setForeground in Frame

Download  my you tube channel  Android application from here-
https://www.dropbox.com/s/stoehcarylm...

How to Create An U IUser Interface Using AWT In Java #1 URL
https://www.youtube.com/watch?v=n9NF1...

path seting-
https://www.youtube.com/watch?v=k2gCo...

java doc-
https://www.youtube.com/watch?v=NLfXd...

Connect on Socials:-
Facebook:- https://www.facebook.com/AndroJavaTec...
Twitter:- https://twitter.com/AndroJavaTech4U
Google Plus:- https://plus.google.com/u/0/+AndroJav...
LinkedIn:- https://www.linkedin.com/in/androjava...

Program-
import java.awt.*;
class GuiApp extends Frame 
{
//Frame f;
Label l,l1,l2;
TextField tf,tf1,tf2;
Button b,b1;
GuiApp(String title)
{
super(title);
 //f=new Frame("GuiApp");
this.setVisible(true);
 setSize(260,200);
  setResizable(false);
  setBackground(Color.yellow);
  setLocation(400,100);
System.out.println(this.getLocation());
l=new Label("Eneter First No");
l1=new Label("Eneter Second No");
l2=new Label("Result:-");
tf=new TextField(10);
tf1=new TextField(10);
tf2=new TextField(10);
b=new Button("Add");
b1=new Button("Sub");
b1.setForeground(Color.red); 
b.setForeground(Color.red); 


 FlowLayout fl=new FlowLayout();

//FlowLayout fl=new FlowLayout(FlowLayout.RIGHT);
//FlowLayout fl=new FlowLayout(20,20,FlowLayout.RIGHT);
//GridLayout fl=new GridLayout(3,3);
//BorderLayout fl=new BorderLayout();
tf.setBackground(Color.pink);
tf1.setBackground(Color.pink);
tf2.setBackground(Color.pink);


this.setLayout(fl);

/*
l.setBackground(Color.pink);
l.setBounds(100,100,90,30);
tf.setBackground(Color.green);
tf.setBounds(200,100,90,30);

l1.setBackground(Color.pink);
l1.setBounds(100,150,120,30);
tf1.setBackground(Color.green);
tf1.setBounds(220,150,90,30);


l2.setBackground(Color.red);

*/
/*
Panel p=new Panel();
p.add(l);
p.add(tf);
p.setBackground(Color.pink);
f.add(p,BorderLayout.EAST);

Panel p1=new Panel();
p1.add(l1);
p1.add(tf1);
p1.setBackground(Color.orange);
f.add(p1,BorderLayout.WEST);

Panel p2=new Panel();
p2.add(l2);
p2.add(tf2);
p2.setBackground(Color.green);
f.add(p2,BorderLayout.NORTH);

Panel p3=new Panel();
p3.add(b);
p3.add(b1);
p3.setBackground(Color.orange);
f.add(p3,BorderLayout.SOUTH);
*/

/*
f.add(l,BorderLayout.EAST);
f.add(tf,BorderLayout.WEST);
f.add(l1,BorderLayout.NORTH);
f.add(tf1,BorderLayout.SOUTH);
f.add(l2,BorderLayout.CENTER);
f.add(tf2);
f.add(b);
f.add(b1);
 */

Panel p1=new Panel();
p1.add(l);
p1.add(tf);
p1.setBackground(Color.green);
 this.add(p1);

Panel p2=new Panel();
p2.add(l1);
p2.add(tf1);
p2.setBackground(Color.green);
 this.add(p2);

Panel p3=new Panel();
p3.add(l2);
p3.add(tf2);
p3.add(b);
p3.add(b1);

p3.setBackground(Color.green);
 this.add(p3);

 }

public static void main(String ss[])
{
GuiApp g=new GuiApp("GuiApp");
}
}

More from this channel