carvalho2707 Posted August 10, 2012 at 11:10 PM Report Share #472004 Posted August 10, 2012 at 11:10 PM 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 More sharing options...
AJBM Posted August 13, 2012 at 10:06 AM Report Share #472127 Posted August 13, 2012 at 10:06 AM 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now