(Apple problem # 3310119)
The applet above attempts to change an Apple System Property.
This applet fails to set false the apple.awt.brushMetalLook property, tested using 1.4.x. Apparently, even using a Java 2 applet using System.setProperty() instead of either Java 1.1 approaches fails to set the property. See the Java 2 version for details.
If you have any insights, workarounds or comments about this test page please contact Mickey Segal. A listing of many Java resources is at this link.
Source code (used for applet on this page; click here for the form using other setAppleProperty method):
import java.applet.*;
import java.awt.*;
public class apple_properties extends Applet {
public void init()
{
// setAppleProperty("awt.showGrowBox", true);
setAppleProperty("awt.brushMetalLook", false);
Frame frame = new java.awt.Frame("A Frame");
frame.setLayout(new GridBagLayout());
Label label = new Label("A Label");
label.setBackground(new Color(255, 200, 255));
frame.setSize(200, 200);
constrain(frame, label, 0, 0, 1, 1,
GridBagConstraints.NORTH, 0, 0, 0, 0, GridBagConstraints.NONE, 0, 0);
frame.validate();
frame.setVisible(true);
}
void setAppleProperty(String s, boolean b)
{
try
{
Class stringClass = Class.forName("java.lang.String");
Class.forName("java.lang.System").getMethod("setProperty", new Class[]{stringClass,
stringClass}).invoke(null, new Object[]{"apple." + s, (b? "true" : "false")});
}
catch (Exception e) {}
}
/*
void setAppleProperty(String s, boolean b)
{
try
{
Class stringClass = Class.forName("java.lang.String");
Class systemClass = Class.forName("java.lang.System");
Class[] argClasses = new Class[]{stringClass, stringClass};
java.lang.reflect.Method setPropertyMethod =
systemClass.getMethod("setProperty", argClasses);
Object[] methodArgs = new Object[]{"apple." + s, (b? "true" : "false")};
setPropertyMethod.invoke(null, methodArgs);
}
catch (Exception e) {}
}
*/
static final void constrain(Container container, Component component, int grid_x, int grid_y,
int grid_width, int grid_height, int anchor, int topPad, int leftPad, int bottomPad,
int rightPad, int fill, double weightx, double weighty)
{
GridBagConstraints c = new GridBagConstraints();
c.gridx = grid_x;
c.gridy = grid_y;
c.gridwidth = grid_width;
c.gridheight = grid_height;
c.anchor = anchor;
c.insets.top = topPad;
c.insets.left = leftPad;
c.insets.bottom= bottomPad;
c.insets.right = rightPad;
c.fill = fill;
c.weightx = weightx;
c.weighty = weighty;
((GridBagLayout)container.getLayout()).setConstraints(component, c);
container.add(component);
}
public void paint(Graphics g)
{
g.drawString("A simple frame with a label should pop up", 10 , 20);
}
} // END OF Class apple_properties