Chinese programming □□and awtbutton on the Button during AWT Programming

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.