Post by hermann krauÃHallo miteinander,
wie krieg ich ein .png als Hintergrundbild für ein JFrame/JPanel/... ?
habs mit dem JFrame.setImageIcon versucht, aber der tuts nicht.
-> der setzt nur das Icon für die Taskleiste
Danke!
Meinst Du so eine Art Wasserzeichen?
Das mache ich immer so:
(hier wird eine TextPane in einer ScrollPane mit Wasserzeichen innerhalb eines
Panels dargestellt; this ist das JPanel)
[...]
textPane.setOpaque(false);
JLabel lbl_Wasserzeichen = new JLabel();
// Laden des Images
ImageIcon image1 = ResourceAccess.getImageIcon("wasserzeichen.png");
lbl_Wasserzeichen.setIcon(image1);
lbl_Wasserzeichen.setOpaque(false);
this.setLayout(gridBagLayout1);
this.setBackground(Color.white);
JScrollPane scroller = new JScrollPane();
scroller.setOpaque(false);
scroller.getViewport().setOpaque(false);
scroller.getViewport().add(textPane, null);
this.add(scroller, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
this.add(lbl_Wasserzeichen, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
0));
[...]
Hoffe, es hilft.
Grüße,
Oliver