I just downloaded Forte (Community Edition v3.0) from Sun to start learing
java. I created a simple new program which creates a JFrame. I want to add a
couple of "label" and "textfield" to the frame (or form?) and I am having
hard time to do that. It sesms
Forty do not allow you to visually add componet after JFrame is selected
visually.
Here is the snip:
------------
public class OpticsReflection extends javax.swing.JFrame {
/** Creates new form opticsreflect */
public OpticsReflection() {
initComponents();
initMoreComponents();
setBounds( 100, 100, 400, 400 );
private void initComponents() {
snip....
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
snip....
pack();
}
private void initMoreComponents() {
iAngleLabel = new javax.swing.JLabel ();
iAngleLabel.setText ("Incident Angle:");
iAngleLabel.setVerticalTextPosition(javax.swing.JLabel.BOTTOM);
iAngleLabel.setHorizontalTextPosition(javax.swing.JLabel.CENTER);
getContentPane().add(iAngleLabel); // <--- this line generated error when
executing the program
}
}
-------
My code seems to compile (no error message), but when I execute, I got:
Error message:
java.lang.IllegalArgumentException
at
org.netbeans.lib.awtextra.AbsoluteLayout.addLayoutComponent(AbsoluteLayout.j
ava:128)
at java.awt.Container.addImpl(Container.java:380)
at java.awt.Container.add(Container.java:267)
at
opticsreflection.OpticsReflection.initMoreComponents(OpticsReflection.java:1
12)
at opticsreflection.OpticsReflection.<init>(OpticsReflection.java:21)
at opticsreflection.OpticsReflection.main(OpticsReflection.java:90)
Question:
1. Does anyone know how to add a label or textfiled (component) to a JFrame
(or layout?) in Forte visually ?
2. If I have to add a label by writing my own code, say in method
"initMoreComponents", what command should I use? could some one give me a
example?
Thanks.
Arnaud
"Guang Mei" <gm...@proteome.com> a écrit dans le message news:
Ii1A7.1057$oc.1...@news.shore.net...