java - Swing: How to make non-rectangular windows with soft borders? -


How can I create non-rectangular windows with soft boundaries in Java?
Soft limitations (also known as

I searched the web a lot and got many posts about translucent and / or non-rectangular windows.

The subject "soft border" is misleading; It seems that the information I have provided deals with implementing soft borders to those components which are inside another Java component.

But, Do I, or I apply soft borders to custom-shaped jade windows which just d

I am referring to the following posts first:

When it comes to soft clipping, then the article is going to proceed
Here, soft clipping is described on an existing graphics 2D object.

Here's a soft-cut, shaped, top-level window to take me. Note: The size windows use a proprietary API (com.sun.awt.AWTUtilities) and non- Is not guaranteed to work on JVMs. However, JDK 7 it becomes part of the window class.

  import java.awt. *; Import java.awt.event.ActionEvent; Import java.awt.image.BufferedImage; Import javax.swing. *; Public square expand myships to ClipWindow JPN {Public MySQLclip Widows () {super}; SetLayout (new gridoutout ()); Jebton Button = New Pocket (New Object Action ("Close") {@ Override Public Void Action Perforated (Action Event E) {System. Ext. (0);}}); Button.setOpaque (wrong); (Button) connecting; } @ Override Public Empty Paint Comonant (Graphics G) {Graphics 2DG2D = (Graphics 2D) G. Cute (); Int width = getWidth (); Int height = getHeight (); // Create a soft cut image for the background BufferedImage img = java_2d_tricker (g2d, width, height); G2d.drawImage (IMG, 0, 0, empty); G2d.dispose (); } Public static zero main (string [] args) {JFrame.setDefaultLookAndFeelDecorated (true); SwingUtilities.invokeLater {New Overall Public} (Overall Public Wired Run Container CP = W. Gate ContentPan (); CP; salesout (new border layout ()); Cp.add (new MySoftClippedWindow ()); W.setAlwaysOnTop (true); Com.sun.awt.AWTUtilities.setWindowOpaque (w, false); wsetset (200, 200); W; setvisible (true);}}); } / * * This code from * http://weblogs.java.net/blog/campbell/archive/2006/07/java_2d_tricker.html * / Personal BufferedImage java_2d_tricker (Graphics 2DG2D, int width, inti height) Is taken {graphics configuration gc = g2d.getDeviceConfiguration (); Buffer image img = gcrite cosmetic image (width, height, transparency. TRANSLUCENT); Graphics2DG2 = IMG.creative graphics (); G2.setComposite (AlphaComposite.Clear); g2.fillRect (0, 0, width, height); g2.setComposite (AlphaComposite.Src); G2.setRenderingHint (Rendering Hicks. KEY_ANTIALASING, Rendering Hints. VALUE_ANTIALIAS_ON); G2.setColor (Color.WHITE); G2.fill oval (width / 4, height / 4, width / 2, height / 2); G2.setComposite (AlphaComposite.SrcAtop); G2.setPaint (New Gradient Paint (0, 0, Color. RED, 0, Height, Color. Yellow)); G2.fillRect (0, 0, width, height); G2.dispose (); Return img; }}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -