Main.java
import pack.*;
import javax.swing.*;
import java.awt.*;
class Main extends JFrame
{
public static void main(String[] s)
{
JFrame f1=new JFrame();
f1.setSize(200,200);
f1.setBackground(Color.blue);
f1.setLayout(null);
f1.setVisible(true);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Pan d1=new Pan();
f1.add(d1);
}
}
-------------------------
Pan.java
package pack;
import javax.swing.*;
import java.awt.*;
public class Pan extends JPanel
{
JLabel l1;
public Pan()
{
setSize(100,100);
setLayout(null);
setBackground(Color.red);
setVisible(true);
setBounds(50,50,80,40);
l1=new JLabel("PANEL");
l1.setBounds(15,15,50,10);
add(l1);
}
}
Output:-
No comments:
Post a Comment