File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes help with button display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "help with button display" Watch "help with button display" New topic
Author

help with button display

karan, chopra
Ranch Hand

Joined: Jun 05, 2001
Posts: 115
guys help me out with this..i wrote an japplet code and placed some jbuttons in it..not the problem is that when i load my applet in a browser(or appletviewer) then the buttons dont show up automatically,they only show up when i scroll my mouse over the region where they are supposed to be displayed..why is this so??following is my init function:
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("Click to read from text file");
But2 = new JButton("Click to read from database");
But3 = new JButton("Click to open database");

contentPane.add(But1);
contentPane.add(But2);
contentPane.add(But3);

But1.addActionListener(this);
But2.addActionListener(this);
But3.addActionListener(this);

//if (!laidOut) {
Insets insets = contentPane.getInsets();
But1.setBounds(v2+20+insets.left,v3+20+insets.top,175,30);
But2.setBounds(v2+20+insets.left,v3+120+insets.top,175,30);
But3.setBounds(v2+20+insets.left,v3+70+insets.top,175,30);
//laidOut = true;
//}
But1.setBackground(Color.lightGray);
But2.setBackground(Color.lightGray);
But3.setBackground(Color.lightGray);
But1.setForeground(Color.blue);
But2.setForeground(Color.blue);
But3.setForeground(Color.blue);
But1.setFont(new Font("TimesRoman",Font.BOLD,11));
But2.setFont(new Font("TimesRoman",Font.BOLD,11));
But3.setFont(new Font("TimesRoman",Font.BOLD,11));
But2.setEnabled(false);
}
regards
karan
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Karen,
Once again, I have used your code and had no problems seeing the buttons. You might want to check your browser for update or use at least JDK1.2. I have tried your code on at least three different platform O/S without any problems (Win98, WinNT, Unix).
Regards,
Manfred.
karan, chopra
Ranch Hand

Joined: Jun 05, 2001
Posts: 115
hi manfred..sorry for bothering u again ..but i really dont know why am i having this problem because i have jdk1.3,i am working on win NT with service pack 5.0,my browser is IE5.0 and netscape 6.0 and i have tried it on all the machines around me having win NT but have the same problem..do u think its a browser problem still or something else..
regards
karan
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Karan,
I am afraid that I don't know how to help you ...
Sorry,
Manfred.
karan, chopra
Ranch Hand

Joined: Jun 05, 2001
Posts: 115
hi manfred..thants ok..thanks anyways for ur help..
regards
karan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help with button display