Home > Back-end >  To ask: why am I here can't set the layout?
To ask: why am I here can't set the layout?

Time:09-25

Red box, write setLayout error?
 
Package com. Chengguo. GUI;

The import javax.mail. Swing. *;
Import the Java. The awt. *;
Import the Java. The awt. Event. An ActionEvent;
Import the Java. The awt. Event. ActionListener;

/* *
* simple computer
*/

Public class Demo_20200506002_Calculator {
Public static void main (String [] args) {

}
}
/* *
* the calculator class
*/
The class Calculator extends Frame {
//three text boxes
TextField num1=new TextField (10);
TextField num2=new TextField (10);
TextField num3=new TextField (20);

//a button
The Button bt=new Button ("=");
//a tag
The Label Label=new Label (" + ");
//layout
Here to write layout error!!!!!!

}
/* *
* event listeners class
*/
The class MyCalcListener implements ActionListener {

@ Override
Public void actionPerformed (an ActionEvent e) {

}
}

CodePudding user response:

Should be written in the structure and layout.

CodePudding user response:

1/f, references from the lion's reply:
should be written in the structure and layout,


The Calculator integration can not direct it I write setLayout (new streaming layout);
Is an error...

CodePudding user response:

refer to the second floor care of migrant workers in mulberry response:
Quote: 1/f, reference from the lion's reply:

Should be written in the structure and layout,


The Calculator integration can not direct it I write setLayout (new streaming layout);
Is an error...

It is not very clear, I am a little blurred, anyway I write are written in the structure,

CodePudding user response:

Layout instructions must be written in the way!!!!!! Class can only write two instructions: in vitro package instructions and import; External methods in the class body can only write variable declaration and initialization statement, static instructions quickly, all other Java instructions must be in the way or static fast writing, where you want to write the layout instructions in place is neither a method body also is not static instructions quickly, so they could go wrong,

CodePudding user response:

refer to the second floor care of migrant workers in mulberry response:
Quote: 1/f, reference from the lion's reply:

Should be written in the structure and layout,


The Calculator integration can not direct it I write setLayout (new streaming layout);
Is an error...


Variable declaration statement outside of the statement can only be written in the code block or method, the foundation is too bad, you take a lot more,
  • Related