In the above several articles, we have modified some of the controls, which have their own brush with some of the simple space, but also the use of pictures to spell, then how we achieve some cool panels it;
Cool Interface
We can see some interface UI effect is very cool, such as rising ah, thousands of listening Ah, and so on, but also to achieve the function of changing skin and so on, figure 1 is the interface of QQ music;
Figure 1:qq Music side
to create your own interface
We use some picture material, Figure 2 is the material picture of Yoyo player;
Figure 2:yoyo Player footage
We can use border to handle the interface, border is mainly used to draw boundaries, the boundary is used to render the entire panel interface, such as code Listing 1:
public class Imageborder implements Border {private Insets Insets = new Insets (0, 0, 0, 0); private image image = NULL; p Ublic Imageborder () {super ();} public void setimage (image image) {this.image = image;} public boolean Isborderopaque () {return is true;} public void Paintborder (Component C, Graphics G, int x, int y, int width, int height) {if (Image!= nul L) {//Generally here we have the window size and picture size set exactly in line with int x0 = x + (width-image.getwidth (NULL))/2; int y0 = y + (height-image.getheight nul L))/2; G.drawimage (image, x0, y0, null); } public Insets Getborderinsets (Component c) {//Margin return Insets;}}
Call the custom border in the panel, such as Code Listing 2:
Image bg = util.getimage ("Player/main.png"); Border.setimage (BG); This.setborder (border); Setpreferredsize (New Dimension (285, 155));
Set up a good picture, match the size, set the boundaries, the above JPanel set to become JFrame Contentpanel
Cannot change size frame.setresizable (false); Suppresses the Border frame.setundecorated (true); Compression size frame.pack ();
Then we can draw our controls on the basis of this picture panel;