Boa tarde galera do guj!
Estou com um problema parecido.
eu montei a tela, porém mesmo que os itens fique para fora do meu JScrollPane ele não desce a barra de rolagem, e a mesma não aparece também.
já tentei:
pane.add(scrollPane);
scrollPane.add(pane);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.Autoscroll(true);
pane.Autoscroll(true);
nada resolve.
Podem me ajudar?
segue abaixo meu código:
import java.awt.BorderLayout;
public class Scroll extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Scroll frame = new Scroll();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Scroll() {
// setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setAutoscrolls(true);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JPanel panel = new JPanel();
panel.setAutoscrolls(true);
panel.setBounds(0, 0, 442, 273);
contentPane.add(panel);
panel.setLayout(null);
JLabel lblCliente = new JLabel();
lblCliente.setBounds(20, 30, 40, 22);
lblCliente.setText("Cliente");
JTextField txtNome = new JTextField();
txtNome.setBounds(70, 30, 240, 22);
JLabel lblEnd = new JLabel();
lblEnd.setBounds(20, 60, 70, 22);
lblEnd.setText("Endereço");
JTextField txtRua = new JTextField();
txtRua.setBounds(80, 60, 240, 22);
JLabel lblEndNum = new JLabel();
lblEndNum.setBounds(330, 60, 70, 22);
lblEndNum.setText("Número");
JTextField txtNum = new JTextField();
txtNum.setBounds(380, 60, 30, 22);
JLabel lblDescriEquip = new JLabel();
lblDescriEquip.setBounds(20, 90, 180, 22);
lblDescriEquip.setText("Descriminação do Equipamento");
JEditorPane edtpDescriEquip = new JEditorPane();
edtpDescriEquip.setBounds(20, 120, 270, 115);
JLabel lblDescriServi = new JLabel();
lblDescriServi.setBounds(20, 240, 180, 22);
lblDescriServi.setText("Descriminação do Serviço");
JEditorPane edtpDescriServi = new JEditorPane();
edtpDescriServi.setBounds(20, 270, 270, 115);
JButton btn = new JButton();
btn.setBounds(320, 220, 90, 25);
btn.setText("Confirma");
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 11, 422, 251);
scrollPane.setAutoscrolls(true);
scrollPane.setLayout(null);
scrollPane.add(btn);
scrollPane.add(txtNome);
scrollPane.add(lblCliente);
scrollPane.add(lblEnd);
scrollPane.add(txtRua);
scrollPane.add(lblEndNum);
scrollPane.add(txtNum);
scrollPane.add(lblDescriEquip);
scrollPane.add(edtpDescriEquip);
scrollPane.add(lblDescriServi);
scrollPane.add(edtpDescriServi);
panel.add(scrollPane);
}
}
A tela é basicamente isso, como posso fazer para o JScrollPane “funcionar”?
abs!