Hey i have a halftransparent image and i want to paint it in a jframe without any borders but the problem is i always see the background of the frame throught the picture not the screen behind the frame like my desktop .
So here is my code :
bothe methodes doesnt work so please help me :D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.image.BufferedImage; import javax.imageio.*; import java.net.*; import java.io.*; import java.awt.Graphics2D; import javax.swing.*; import java.awt.*; public class test extends Actor { public static void test1() throws Exception { BufferedImage Image = ImageIO.read( new File( "C:\\Users\\Marc\\Desktop\\Bilder\\Kreis.png" )); JFrame frame = new JFrame(); frame.setUndecorated( true ); frame.setOpacity( 1 .0f); frame.getContentPane().setLayout( new FlowLayout()); frame.getContentPane().add( new JLabel( new ImageIcon(Image))); frame.pack(); frame.setVisible( true ); } public static void test2() { JPanel p = new JPanel(); p.setLayout( null ); p.setForeground(Color.blue); p.setBackground(Color.black); p.setOpaque( true ); p.setBounds( 0 , 0 , 100 , 100 ); JFrame f = new JFrame( "Two Panels" ); f.setContentPane(p); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize( 300 , 300 ); f.setUndecorated( true ); f.setLocationRelativeTo( null ); f.setVisible( true ); } } |