protected HeaderPanel headerPanel;
public void repositionHeader() {
this.remove(headerPanel);
this.setColumnHeaderView(headerPanel);
}
ich fange einfach den Event der ScrollBar ab und führe dann folgende Methode auf der JScrollPane aus [...]
class FixedHeaderViewport extends JViewport {
@Override
public void setViewPosition(Point p) {
super.setViewPosition(new Point(0, 0));
}
@Override
public Dimension getExtentSize() {
return getSize();
}
}
public MyPlotScrollPane(Component c, OverviewModel model, Controller controller){
super(c);
this.chromeModel = chromeModel;
headerPanel = new ChromosomeHeaderPanel(this.chromeModel, controller);
getHorizontalScrollBar().addAdjustmentListener(controller);
getVerticalScrollBar().addAdjustmentListener(controller);
this.setViewport(new FixedHeaderViewport());
this.setColumnHeaderView(headerPanel);
}
class FixedHeaderViewport extends JViewport {
public void setViewPosition(Point p) {
super.setViewPosition(new Point(0, 0));
}
public Dimension getExtentSize() {
return getSize();
}
}
public HeaderPanel(OverviewModel model, Controller controller){
this.model= model;
// Wie lege ich die größe meines HeaderPanels fest?
int width = this.model.getWidth_panel();
int height = this.model.getHeight_Panel();
int pos_x = this.model.getLocation_panel_X();
int pos_y = this.model.getLocation_panel_Y();
this.setSize(new Dimension(width,height));
this.setPreferredSize(new Dimension(width,height));
this.setBounds(pos_x,pos_y,width,height);
this.setBackground(Color.white);
}