hey puneri i need some more help from you..i was wondering if u could bail me out...actually the problem is that my applet ia a JApplet and in that i have some buttons.so the problem is that when i load the applet(either in appletviewer or in a browser) then the buttons dont show up automatically but only when i scroll my mouse over the region where they are supposed to be displayed.why is this so?
for your information,i am using a contentpane and setting the layout to null.,following is the code for the same..
public class Simple extends JApplet implements ActionListener{
String msg = "The Design Network";
static int pointWidth = 4;
static int pointHeight = 4;
public static double[][] arr1 = new double[100][100]; //stores the respective node number and its X & Y co-ord.
public double[] arr2 = new double[10]; //stores the total no of nodes in the file and the scale factors
public static double[][] arr11 = new double[100][100]; //stores the respective link number and its details
public static double[] arr22 = new double[10]; //stores the total no of links in the file and the scale factors
public static double[][] inc = new double[100][100];
public int[][] h = new int[100][10];
public int[][] in = new int[100][10];
public static double tokens;
static int i;
public int test=0;
private JButton But1, But2, But3;
private boolean laidOut = false;
public int width,height;
public int v1,v2,v3,v4,v5;
public void init(){
setBackground(Color.black);
Container contentPane = getContentPane();
contentPane.setLayout(null);
width = Integer.parseInt(getParameter("width"));
height = Integer.parseInt(getParameter("height"));
v1 = (int)(height/9);
v2 = (int)(0.8*width);
v3 = v1+10;
v4 = v2/2-10;
v5 = v3+50;
But1 = new JButton("Text Format Input");
But2 = new JButton("Mdb Format Input");
contentPane.add(But1);
contentPane.add(But2);
But1.addActionListener(this);
But2.addActionListener(this);
//if (!laidOut) {
Insets insets = contentPane.getInsets();
But1.setBounds(v2+50+insets.left,v3+20+insets.top,130,30);
But2.setBounds(v2+50+insets.left,v3+70+insets.top,130,30);
//laidOut = true;
//}
But1.setBackground(Color.lightGray);
But2.setBackground(Color.lightGray);
But1.setForeground(Color.blue);
But2.setForeground(Color.blue);
But1.setFont(new Font("TimesRoman",Font.BOLD,11));
But2.setFont(new Font("TimesRoman",Font.BOLD,11));
}
public void actionPerformed(ActionEvent ae){
String str = ae.getActionCommand();
if(str.equals("Text Format Input")){
test=1;
}
else{
test=2;}
repaint();
}
public void paint(Graphics g){
g.setColor(Color.lightGray);
g.fillRect(0,v1,1300,10);
g.fillRect(v2,v3,10,1000);
try{
drawPoint(g);
}catch(Exception e){System.out.println("U Dumbo!");}
try{
drawlink(g);
}catch(Exception e){System.out.println("screwed up!");}
try{
g.setColor(Color.red);
inclink(g);
}catch(Exception e){System.out.println("screw u!");}
draw(g);
}
}
this is just the part where i am using the buttons..
plz help me out..
thanks in advance
karan