Note that there are some explanatory texts on larger screens.

plurals
  1. PORe-paint on translucent frame/panel/component.
    text
    copied!<p>I'm trying to create a translucent window with Java on OSX and add a <code>JLabel</code> to it. </p> <p>This <code>JLabel</code> changes its text every second.... </p> <p><img src="https://web.archive.org/web/20150413162831/http://img641.imageshack.us/img641/8873/translucentfail.png" alt="alt text"></p> <p>However the component is not repainting well. </p> <p>How can I solve this problem?</p> <p>I've found the <a href="http://web.archive.org/web/20080701100122/http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/" rel="nofollow noreferrer">these</a> <a href="http://www.curious-creature.org/2007/04/10/translucent-swing-windows-on-mac-os-x/" rel="nofollow noreferrer">articles</a>, but I can't figure out how to solve it. </p> <p>If possible, please paste the fixing source code, here's mine:</p> <pre><code>import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.Color; import java.awt.Font; import java.util.Timer; import java.util.TimerTask; public class Translucent { public static void main( String [] args ) { JFrame frame = new JFrame(); frame.setBackground( new Color( 0.0f,0.0f,0.0f,0.3f)); final JLabel label = new JLabel("Hola"); label.setFont( new Font( label.getFont().getFamily(), Font.PLAIN, 46 ) ); label.setForeground( Color.white ); frame.add( label ); frame.pack(); frame.setLocationRelativeTo( null ); frame.setVisible( true ); Timer timer = new Timer(); timer.schedule( new TimerTask(){ int i = 0; public void run() { label.setText("Hola "+ i++ ); } }, 0, 1000 ); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload