Inserting a picture in the Java graphical interface

Source: Internet
Author: User

classpictureshow{JFrame FR1,FR2;        JLabel Picturelabel1,picturelabel2;        JPanel pan1,pan2; PictureShow () {} Public voidShow1 () {FR1=NewJFrame ("Show map based on the location of the hotel"); Pan1=NewJPanel (); PictureLabel1=NewJLabel (NewImageIcon (". \\picture1.png"));//relative PathPan1.add (PictureLabel1, Borderlayout.center);        Fr1.setcontentpane (PAN1);        Fr1.pack (); Fr1.setvisible (true); }     Public voidShow2 () {FR2=NewJFrame ("Show map based on Hotel Price"); Pan2=NewJPanel (); PictureLabel2=NewJLabel (NewImageIcon ("D:\\eclipse\\workbench\\zyq_kmeans\\picture2.png"));//Absolute PathPan2.add (PictureLabel2, Borderlayout.center);        Fr2.setcontentpane (PAN2);        Fr2.pack (); Fr2.setvisible (true); }}

Inserting a picture in the Java graphical interface

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.