Java World transparency

Source: Internet
Author: User

There are many parameters in Java that can make the components transparent to users! I think this is better.

First, the component transparency:

In Java components, except for some restrictions on jlabel and label, they are set as Java components that do not draw borders.

I have been doing something about Java swing recently. Although it is said that the current rolling wing is not very popular, it is only necessary to change some of the classic components of the rolling wing.

There are many parameters in Java that can make the components transparent to users! I think this is better.

First, the component transparency:

In Java components, except for some restrictions on jlabel and label, they are set as Java components that do not draw borders.

Swingbutton =NewJbutton ("swingbutton ");

Swingbutton. setopaque (True);

FinalJlabel label =NewJlabel ("label ");

Label. setopaque (isopaque ());

 

Public voidSetopaque(Boolean isopaque)

If true, the component draws all pixels within its boundary. Otherwise, the component may not draw part or all pixels, so that the underlying pixels can be viewed.

For jcomponent, the default value of this attribute is false. However, for most standard jcomponent subclasses (such as jbutton and jtree), the default value of this attribute is related to the appearance.

Public BooleanIsopaque()

If this component is completely opaque, true is returned.

The opacity component draws each pixel within its Rectangular boundary. A transparent component only draws part of the pixels or does not draw any pixels, allowing its underlying pixels to be "pivoting out ". Therefore, components that do not completely draw their pixels provide a certain degree of transparency.

Make sure that the subclass that always draws its content should override this method and return true.

 

There is also a robot class in Java. I believe you have seen a lot about Java on the Internet.

Write a magnifier program, which also reflects the Java transparent feature. In addition, some attributes that have been seen in the new version of Java (JDK) can be directly set to transparent or transparent to some Java components.

 

 

This is a code snippet written by a netizen on the Internet: it shows the desktop magnifier function:Private int relativecoordinateywhenmousepressed; </P> <p>/** </P> <p> * indicates whether the mouse is pressed. If you press it, it is true; otherwise, it is false </P> <p> */</P> <p> private Boolean mousepressednow; </P> <p>/** </P> <p> * magnifier size </P> <p> */</P> <p> private int magnifiersize = 100; </P> <p>/** </P> <p> * magnifier content panel </P> <p> */</P> <p> private magnifierpanel = new magnifierpanel (magnifiersize ); </P> <p>/** </P> <p> * constructor, create a magnifier form </P> <p> */</P> <p> Public magnifier () </P> <p >{</P> <p> setundecorated (true); // form edge </P> <p> setresizable (false ); </P> <p> container. add (magnifierpanel); </P> <p> addmouselistener (New mousefunctions (); </P> <p> addmousemotionlistener (New mousemotionfunctions ()); </P> <p> updatesize (magnifiersize); </P> <p> This. setvisible (true); </P> <p >}</P> <p>

 

So in the Java World, everything will be "Transparent"

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.