Good afternoon comrades, today I have a question that has blown my mind for almost an hour thinking it was something simple.
I have a jtable with its respective jscrollbar.
And add a button so that the table can be resized to a larger size (without maximizing the window).
The parent layout is absolute and the event code is.
private void btnMenuActionPerformed(java.awt.event.ActionEvent evt) {
int posicion = btnMenu.getX();
if (posicion>5) {
Animacion.Animacion.mover_izquierda(-5, -255, 5, 5, pnlMenu);
Animacion.Animacion.mover_izquierda(240, 0, 5, 5, btnMenu);
Animacion.Animacion.mover_izquierda(245, 20, 5, 5, jScrollPane2);
//jScrollPane2.setBounds(20, 60, 2000, 820);
jScrollPane2.setSize(new Dimension(1265, 820));
jScrollPane2.setMinimumSize(new Dimension(1265, 820));
jScrollPane2.setMaximumSize(new Dimension(1265, 820));
} else {
Animacion.Animacion.mover_derecha(-255, -5, 5, 5, pnlMenu);
Animacion.Animacion.mover_derecha(0, 240, 5, 5, btnMenu);
Animacion.Animacion.mover_derecha(20, 245, 5, 5, jScrollPane2);
//jScrollPane2.setBounds(245, 60, 1020, 820);
jScrollPane2.setSize(new Dimension(1020, 820));
jScrollPane2.setPreferredSize(new Dimension(1020, 820));
}
}
In short, I have an initial button in a position X, which when I press it activates a scrolling effect in the menu (hiding to the left), then the table or more precisely the scrollpane is also moved (also to the left) and even here everything works.
The next thing I wanted was for the table to resize so that it increased in width and better filled the panel.
I have tried all the methods you can see starting from setBounds and none of them work. The table just scrolls left but doesn't resize.
It would be very helpful if you could help me.
Thank you!
hello first you can try to add your
Jtable
to your ScrollPanethen in your event you change the dimensions of your ScrollPane and then add back the
jtable
and this will makeJtable
your resize according to your scrollpane.