Pessoal, eu tenho um Jpanel dentro de um JScrollPane. Acontece que a barra de rolagem não está aparecendo.
Alguém pode me ajudar?
public class Sheet extends JPanel {
private JScrollPane scroll;
private JLabel labelOrigem = new JLabel(“Colunas de Origem”);
private JLabel labelDestino = new JLabel(“Colunas de Destino”);
private JSeparator separator = new JSeparator(SwingConstants.VERTICAL);
private JTextField sheeetNumField = new JTextField();
private JTextField[][] colunasArr = new JTextField[30][2];
private JTextField textFieldA, textFieldB;
private final int PONTO_A = 150;
private final int PONTO_B = 345;
private int alturaCampo = 40;
private int numSheet;
private String[][] colunasStrArr = new String[15][2];
public Sheet(){
this.setLayout(null);
Border pathNumSheet = BorderFactory.createTitledBorder("Index");
Font font = new Font("Courier", Font.BOLD,20);
sheeetNumField.setBorder(pathNumSheet);
sheeetNumField.setBackground(new Color(238,238,238));
sheeetNumField.setFont(font);
adiciona(sheeetNumField, 10, 10, 50, 50);
adiciona(labelOrigem, 100, 0, 150, 50);
adiciona(labelDestino, 300, 0, 150, 50);
adiciona(separator, 250, 20, 1, 320);
for(int i=0; i<30; i++){
textFieldA = new JTextField();
textFieldB = new JTextField();
adiciona(textFieldA, PONTO_A, alturaCampo, 20, 20);
adiciona(textFieldB, PONTO_B, alturaCampo, 20, 20);
colunasArr[i][0]= textFieldA;
colunasArr[i][1]= textFieldB;
alturaCampo = alturaCampo+20;
}
scroll = new JScrollPane();
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setViewportView(this);
}
private void adiciona( Component Componente , int nColuna , int nLinha , int nLargura , int nAltura ) {
this.add( Componente ) ;
Componente.setBounds( nColuna , nLinha , nLargura , nAltura );
}
}