在半透明的框架/面板/组件上重新油漆。
JLabel
JLabel
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 ); } }
慕娘9325324