JLayeredPane in JScrollBox

Tico

Mitglied
Hallo Leute,

mein Problem ist folgedes: Ich habe eine Klasse geschrieben, die JScrollPane erweitert. Als Viewport nutze ich ein JLayeredPane. Dieses Pane enthält ein JPanel, das wiederum einen JButton enthält. Mein Problem ist nun, dass das JScrollpane nicht scrollt, wenn ich die Höhe des LayeredPane größer mache, als die vom ScrollPane. Ich nutze das NULL-Layout. Hier mein Code;

Java:
public class NewProblemAHPgui extends JScrollPane
{
	private static final long serialVersionUID = 1L;
	
	private JPanel panel;
	private JLayeredPane box;
	
	private JButton previous;
	
	public NewProblemAHPgui(int width, int height)
	{
		this.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		this.setBounds(0,0,width,height);
		this.setSize(width,height);
		
		box = new JLayeredPane();		
		box.setLayout(null);
		box.setBounds(0, 0, width, height+200);
		box.setSize(width,height+200);
		
		panel = new JPanel();
		panel.setLayout(null);
		panel.setBounds(0, 0, width, height+200);
		panel.setSize(width,height+200);
		panel.setBackground(Color.WHITE);
				
		previous = new JButton("previous");
		previous.setLayout(null);
		previous.setBounds(200, 420, 100, 30);
		previous.setSize(100, 30);
		
		this.setViewportView(box);
		box.add(panel,0);
		panel.add(previous);
	}
}

Bin für jede Hilfe dankbar.

Gruß
 
Hi.

Hehe danke, so funktioniert es top. Ich weiß, ist nicht das eleganteste mit dem Layout und mehr Aufwand, aber ich mag die anderen Layouts nicht 😀 .

Gruß
 

Neue Themen


Zurück
Oben