Salve,
e grazie per le risposte, il problema però persiste
nella guida che mi hai passato come nella documentazione di java dice di usare
gridBag.fill = GridBagConstraints.BOTH;
gridBag.anchor = GridBagConstraints.NORTH;
per disporre gli elementi
quello che ottengo però continua ad essere

mentre io voglio qualcosa del genere

forse succede per tutto il nesting di panel diversi
tabbed<scroll<panel
o più probabilmente sono io che non capisco come disporre gli elementi
quello che mi serve in pratica è avere un tab con dei contenuti che possono eccedere la dimensione della tabella mostrando una barra di scorrimento
codice:
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JScrollPane;
import java.awt.GridBagLayout;
public class Prova extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JTabbedPane jTabbedPane = null;
private JScrollPane jScrollPane = null;
private JPanel jPanel = null;
/**
* This is the default constructor
*/
public Prova() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(519, 442);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJTabbedPane(), BorderLayout.CENTER);
}
return jContentPane;
}
/**
* This method initializes jTabbedPane
*
* @return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
jTabbedPane.addTab("Prova", null, getJScrollPane(), null);
}
return jTabbedPane;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJPanel());
}
return jScrollPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
for(int i = 0; i<4; i++){
jPanel.add(new JButton("Prova a"+i), gridBagFactory(i, 0, 1));
jPanel.add(new JButton("Prova b"+i), gridBagFactory(i, 1, 1));
jPanel.add(new JButton("Prova c"+i), gridBagFactory(i, 2, 1));
jPanel.add(new JButton("Prova d"+i), gridBagFactory(i, 3, 1));
}
}
return jPanel;
}
private GridBagConstraints gridBagFactory(int coordY, int coordX, double weightX){
GridBagConstraints gridBag = new GridBagConstraints();
gridBag.fill = GridBagConstraints.BOTH;
gridBag.anchor = GridBagConstraints.NORTH;
gridBag.insets.top = 0;
gridBag.gridy = coordY;
gridBag.weightx = weightX;
gridBag.gridx = coordX;
return gridBag;
}
}
così si dovrebbe capire meglio
grazie per l'aiuto