Chinese programming □□and awtbutton on the Button during AWT Programming
When learning AWT programming today, follow the code in the book. The Code is as follows:
Import java. awt .*;
Public class PanelTest
{
Public static void main (String [] args)
{
Frame f = new Frame ("bear ");
// Create a Panel container
Panel p = new Panel ();
// Add two components to the Panel container
P. add (new TextField (20 ));
P. add (new Button ("Click me "));
// Add the Panel container to the Frame window
F. add (p );
// Set the window size and position
F. setBounds (250,120 );
// Display the window (the Frame object is hidden by default)
F. setVisible (true );
}
}
"□□□" Is displayed on the" Click me "Button in the result ",
Then Baidu, some of them say it is to change the two attributes after f. setBounds (), but it still cannot be displayed after I change it.
Then I asked my friend, he said that JFrame should not be used as a Frame. After I changed it, it could be displayed normally, but I think Swing programming is
Based on AWT, I should learn AWT first, so I tried to solve this problem and finally found this method:
Change it to this.