Ich möchte einen textArea zeigen, der einen Text zeigt (wird Loglinien anzeigen), und habe ein animiertes Gif Hoover darüber. Ich habe die beschriebene Lösung here versucht, aber alles, was ich bekomme, ist ein grauer Bildschirm. Hinweise?Swing: Zeige ein transparentes Panel über einem anderen Panel
public class TestLayeredPanes {
private JFrame frame = new JFrame();
private JLayeredPane lpane = new JLayeredPane();
public TestLayeredPanes() {
frame.setPreferredSize(new Dimension(600, 400));
frame.setLayout(new BorderLayout());
frame.add(lpane, BorderLayout.CENTER);
//Build the animated icon
JLabel buildingIcon = new JLabel();
buildingIcon.setIcon(new ImageIcon(this.getClass().getResource(
"/com/ct/tasks/cmviewer/gui/progress_bar.gif")));
JPanel iconPanel = new JPanel();
iconPanel.add(buildingIcon);
//Build the textArea
JTextArea textLog = new JTextArea("Say something");
JPanel textPanel = new JPanel();
textPanel.add(new JScrollPane(textLog));
//Add the panels to the layered pane
lpane.add(textPanel, 0);
lpane.add(iconPanel, 1);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
new TestLayeredPanes();
}
}
Es hat funktioniert, aber ich weiß immer noch nicht, warum die andere Lösung nicht. – Yossale