Thank you Maneesh.
Since yesterday I staretd programming GUI in my machine.
Till now I never wrote a siingle program abt GUIs.Just gone through tutorials in the net.
I used Flow Layout Manager,GridLayout and BorderLayout.Just to experiment I set setLayout to null and set bounds.
Two more issues are bothering me.
1) What ever the layout manager I use, If I resize the frame I created,I cant view the resized frame.it is oon the top of my command prompt window but just as a thin liine showing Frame title and with maximize,minimize and close buttons.
Why it is so?
2) If I wont write System.exit(0) in my code Iam left with an open Dos prompt if I write the newly created frame is just disappearing after creation.
Hope you will clear these too.
I had gone through
translate(int x,int y) in
Graphics class.
it will change the origin to the position indicated in x,y fields right?
Why did you ask me to go through this method?
My code is as follows
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class createFrame extends JFrame
{
public static void main(
String[] args)
{
createFrame f1 = new createFrame();
}
public createFrame()
{
setTitle("frame 1");
setVisible(true);
Container c = getContentPane();
c.setLayout(null);
JButton bt1 =new JButton("Button1");
JButton bt2= new JButton("Button2");
JButton bt3= new JButton("Button3");
JButton bt4= new JButton("Button4");
JButton bt5= new JButton("Button5");
JButton bt6= new JButton("Button6");
JLabel lb1= new JLabel("Label1");
JLabel lb2=new JLabel("Label2");
JTextField txt1=new JTextField();
JTextField txt2=new JTextField();
c.add(bt1);
c.add(bt2);
c.add(bt3);
c.add(bt4);
c.add(bt5);
c.add(bt6);
c.add(lb1);
c.add(lb2);
c.add(txt1);
c.add(txt2);
bt1.setBounds(50,30,80,60);
bt2.setBounds(140,30,80,60);
bt3.setBounds(50,120,80,60);
bt4.setBounds(140,120,80,60);
bt5.setBounds(50,190,80,60);
bt6.setBounds(140,190,80,60);
lb1.setBounds(90,250,80,60);
lb2.setBounds(170,250,80,60);
txt1.setBounds(300,30,80,40);
txt2.setBounds(300,120,80,40);
// System.exit(0);
}
}
The last thing is is it ok to start programming GUI with swings rather than AWT classes?