#1 10. Februar 2011 Scrollbar mit JTextArea Hey, also mein Problem ist, ich hab nen Script geschrieben was mir normalen Text in Brain umwandelt. Hab das alles auch schön mit graphischer Ein- und Ausgabe gemacht. Nur hätte ich noch gerne bei der Ausgabe wenn der Text zu lang wird eine Scrollbar. Bekomme das aber mit Internet / Google etc nicht so wirklich hin :/ Könnte mir da vielleicht wer helfen? Ich poste hier mal, da das Script ziemlich lang ist nur die Output-Section. Bw is ehrensache. Danke schon mal für die Hilfe. Code: // Display output JFrame f = new JFrame( "Code" ); f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); f.setLayout( null ); f.setSize( 400, 400); f.setResizable( false ); JTextArea textAreaOutput = new javax.swing.JTextArea( ausgabe ); JTextArea textAreaInput = new javax.swing.JTextArea( eingabe ); JScrollPane scrollpaneOutput = new JScrollPane( textAreaOutput ); JScrollPane scrollpaneInput = new JScrollPane( textAreaInput ); textAreaInput.setLineWrap( true ); textAreaOutput.setLineWrap( true ); scrollpaneOutput.createHorizontalScrollBar(); scrollpaneInput.createHorizontalScrollBar(); scrollpaneOutput.setVisible( true ); scrollpaneInput.setVisible( true ); textAreaOutput.setEditable( false ); textAreaInput.setEditable( false ); textAreaInput.setLocation( 0, 0 ); textAreaOutput.setLocation( 0, ( f.getHeight() / 2 ) ); textAreaInput.setSize( f.getWidth(), ( f.getHeight() / 2 ) ); textAreaOutput.setSize( f.getWidth(), ( f.getHeight() / 2 ) ); textAreaOutput.setBorder( BorderFactory.createLineBorder( Color.black ) ); textAreaInput.setBorder( BorderFactory.createLineBorder( Color.black ) ); f.add( textAreaOutput ); f.add( textAreaInput ); f.setLocationByPlatform( true ); f.setVisible( true ); MfG JudasIscariot + Multi-Zitat Zitieren
#2 10. Februar 2011 AW: Scrollbar mit JTextArea Hab hier das folgende gefunden: Mfg Rushh0ur + Multi-Zitat Zitieren
#3 11. Februar 2011 AW: Scrollbar mit JTextArea Versuch mal anstatt Code: scrollpaneOutput.createHorizontalScrollBar(); das hier: Code: scrollpaneOutput.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JScrollPane.html#setHorizontalScrollBarPolicy%28int%29 Gruß, Figger //sehe grad, dein Problem ist dass du die TextArea addest, musst aber das ScollPane (welches die TextArea enthält) adden, dann müsste es gehen. Orientier dich einfach an dem Code von Rushh0ur. + Multi-Zitat Zitieren