I have an Applet program, which can be run from Eclipse directly for testing. I am setting window size of this Applet. But, I am seeing sometimes the applet opens with smaller window rather than the actual window size is set, and sometimes it opens with the proper set size setSize(550, 650);
I couldn't get fix for why sometimes it opens with the smaller window. Could someone advise me to fix this issue?
public class HomeApplet extends Applet implements ActionListener
{
public void init() {
titleStr = "Welcome to Application Home page!";
connectBtn = new Button("Submit");
connectBtn.addActionListener(this);
add(connectBtn);
connectBtn.setBounds(100, 120, 90, 20);
connectBtn.setEnabled(true);
setLayout( null );
setSize(550, 650);
sharedImage = new ImageIcon("sameer15.jpg" ).getImage();
}
public void paint (final Graphics g)
{
//super.paint(g);
int x = getSize().width;
int c1 = x/2;
Font titleFont = new Font("Arial", Font.BOLD, 20);
g.setFont(titleFont);
g.drawString(titleStr, c1-170, 20);
Font connectFont = new Font("Arial", Font.BOLD, 15);
g.setFont(connectFont);
g.drawString(connectStr, c1-190, 80);
g.drawImage(sharedImage, 100, 100, this);
System.out.println("drawImage");
}
}