mausam
Posts: 243
Nickname: mausam
Registered: Sep, 2003
|
|
Re: ANOTHER QUESTION
|
Posted: Sep 2, 2003 11:39 PM
|
|
Your questions in bold and my understandings in italic...
but i dont uderstand the class ComponentUtilities, what does it do? why there is this loop "for"? What does it mean return (Frame)c;
Class ComponentUtilities is an Helper class to find who is a Parent of a component.You can make your piece of code run without ComponentUtilities. Use the following line of code.
Frame frame = (Frame)aplet.getParent();
//Instead of
//Frame frame = ComponentUtilities.getTopLevelParent(aplet);
//in MessageWindow
return (Frame)c means the component c is typecaste into Frame and then returned.
Besides please tell me, why after removing line java.awt.Point aploc = aplet.getLocation(); it still working good?
Because after
java.awt.Point aploc = aplet.getLocation();
aploc is not used anywhere. You could use the location of applet aploc in the following piece of cod
tn.setLocation(200, 300); //here u can set location relative to ur aploc values so that u can adjust ur window in the center of applet.
and why when i change public static Frame getTopLevelParent(Component component) to public static Frame getTopLevelParent(Applet component)
Because component is the parent of Applet.If you use Applet component u can not use that method for other componennts althouh it may work fine for ur case. It was simply a generic method to accomodate all case. Heirarchy is as
<pre> java.lang.Object | +-java.awt.Component | +-java.awt.Container | +-java.awt.Panel | +-java.applet.Applet </pre>
And how to make black thin borders around my applet
Hmm what i think of it as of now is in ur html add applet tag to a table and set border to htnl table
<table cellspacing=0 cellpadding=0 vspace=0 border=1 > <tr> <td> <APPLET height=349 width=505 code=QueryApplet.class VIEWASTEXT> </APPLET> </td> </tr> </table>
or pass a parameter border to ur applet and read
s2 = getParameter("border");
boolean border = s2 != null && (s2.charAt(0) == 'y' || s2.charAt(0) == 'Y');
and use the following two methods in ur applet
public void paint(Graphics g)
{
update(g);
}
public void update(Graphics g)
{
if (border)
{
Dimension dimension = size(); //actually size() is depreciated.Better to use getSize() if u have jdk after JDK1.1
g.setColor(Color.black);
g.drawRect(0, 0, dimension.width - 2, dimension.height - 2);
g.drawRect(1, 1, dimension.width - 4, dimension.height - 4);
}
}
And why if i change Component to Container it works ?
See the hierarchy...conatiner extends component so it works
Now ur class Field Age
First of all ur method Sluchaj() is not getting called so listner is not added to ur FiledAge.
Change ur constructor like
FieldAge(){
super();
Sluchaj();
}
And modify ur public void keyReleased(KeyEvent evt) method to include
ile=Rob.length();
if (ile>=3){
this.setText(Rob.substring(0,3));
this.setCaretPosition(3);
return;
// break;
}
Hope that will help...I think i need a break now..what do u say
|
|