Hi ,
I got this problem
" iam not able to add components to the frame(JFrame) which i created it below is the code which i used if u got any suggestions please do advice me
bye
import java.util.*;
import java.awt.Graphics;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
public class Swg extends JFrame implements ActionListener
{
Timer tm;
JLabel l1,l2;
JTextField t1,t2;
JButton b1,b2;
JPanel pn;
Swg()
{
tm = new Timer(10000,this);
tm.start();
java.awt.Container cn = this.getContentPane();
pn = new JPanel();
l1 = new JLabel("User ID");
t1 = new JTextField(10);
l2 = new JLabel("Password");
t2 = new JTextField(10);
b1 = new JButton("Login");
b2 = new JButton("Exit");
pn.add(l1);
pn.add(t1);
pn.add(l2);
pn.add(t2);
pn.add(b1);
pn.add(b2);
cn.add(pn);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == tm)
{
System.exit(0);
}
repaint();
}
public void paint (Graphics g)
{
setForeground(java.awt.Color.orange);
g.fillRect(0,0,500,200);
setForeground(java.awt.Color.black);
g.drawString("HELLOOOOOOO",30,30);
}
public static void main(
String[] args)
{
JFrame f = new Swg();
f.setSize(500,200);
f.setLocationRelativeTo(null);
f.setUndecorated(true);
f.show();
}
}//eof clas Swg