201671010131 2016-2017-2 "Java Programming"

Source: Internet
Author: User

This week, I learned graphic programming.

The basic content is: simple graphics frame construction.

Eventqueue.invokelater (()
{
Simpleframe frame = new Simpleframe ();

Frame.settitle ();
Frame.setdefaultcloseoperation (Jframe.exit_on_close);
Frame.setvisible (TRUE);
});

private static String message;

public static String GetMessage () {
return message;
}
Public Simpleframe ()
{
SetSize (Default_width, default_height);
}

Writing of graphical cues: Fra.settitle ("welcome!"); /Window Prompt

Frame positioning:

Set frame width, height and let platform pick

SetSize (SCREENWIDTH/2, SCREENHEIGHT/2);//long, wide, half the screen,
Setlocationbyplatform (TRUE);//determines where the frame is placed.

To display information in the component:

public void Paintcomponent (Graphics g)//Describes methods for drawing components.
{
graphics2d g2 = (graphics2d) g;

Draw a rectangle

Double LEFTX = 100;
Double topy = 100;
Double width = 200;
Double height = 150;.. }

There is also the construction of the graphics in the component:

Public Drawframe ()
{
Add (New Drawcomponent ());//Adds a given component to the contents pane, which is titled Rectangle.
Pack ();//Adjust window size.
}

Rectangle2D rect = new Rectangle2d.double (LEFTX, topy, width, height);
G2.draw (rect);

G2.draw (New Line2d.double (LEFTX, topy, Leftx + width, topy + height);//. The position and height of the upper left corner.

Multiple windows can be generated, but not multi-layered.

201671010131 2016-2017-2 "Java Programming"

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.