Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /is/htdocs/wp1046144_7A5NSU4UX7/www/philipp/wp/wp-content/plugins/wp-syntax/wp-syntax.php on line 383
I had this problem that my applet was always showing this 5 pixel border at the top – like you can see in the left Screenshot…
…so I was looking for a resulotion for that. In the end it was hard to guess but simple: I just had to add the line setLayout(new BorderLayout()); to make it work according to the Image on the right. But why does it have this 5 pixel? I have no clue. Doesn’t really make sense. Do you know? Here is my Code for your testing:
import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JLabel; public class Main extends Applet{ private static final long serialVersionUID = 1L; JLabel myJLabel; public void init() { this.setBackground(Color.green); myJLabel = new JLabel ("Test"); myJLabel.setBackground(Color.yellow); myJLabel.setOpaque(true); // Prevent border on top setLayout(new BorderLayout()); this.add("Center", myJLabel); } } |
PS: You may want to set the Background-Color to black – otherwise you will have ugly green flickers…