Jump to content

JScrollPane / Bar


carvalho2707

Recommended Posts

boas, tenho o meu programa quase terminado , falta-me so criar um scroll para descer na caixa de texto..

ja li em varios sites mas nenhum me ajuda realmente

final JTextArea textArea1 = new JTextArea(5, 50);
 textArea1.setEditable(false);
 textArea1.setLineWrap(true);
 textArea1.setBounds(15, 266, 812, 223);
 contentPane.add(textArea1);

 final JScrollPane barra = new JScrollPane(textArea1);
 barra.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
 barra.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
 barra.setToolTipText("");
 barra.setBounds(654, 266, 17, 223);
 contentPane.add(barra);

esta assim definida a caixa de texto e o scroll.. contudo quando executo o programa a caixa de texto desaparece..

e se retirar o argumento em :

final JScrollPane barra = new JScrollPane(textArea1);

aparece novamente mas o scroll nao funciona :/

o que posso fazer?

Link to comment
Share on other sites

Boas!! Podes fazer isto

JTextArea textArea1 = new JTextArea(5, 50);
    JPanel panel = new JPanel();
    textArea1.setEditable(false);
    JScrollPane barra = new JScrollPane(textArea1);
    textArea1.setEditable(false);
    textArea1.setLineWrap(true);
    textArea1.setBounds(15, 266, 812, 223);
    this.setLayout(new BorderLayout());
    this.add(panel);
    barra.setHorizontalScrollBarPolicy(barra.HORIZONTAL_SCROLLBAR_NEVER);
    barra.setVerticalScrollBarPolicy(barra.VERTICAL_SCROLLBAR_ALWAYS);
    barra.setToolTipText("");
    barra.setBounds(654, 266, 17, 223);
    panel.add(barra, BorderLayout.CENTER);


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.