Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How do I add a scroll pane to a text area

$
0
0
I looked around online and tried several ways of adding a scroll pane to a text area, but so far I havent been able to get it to show up.

Any ideas? Here is my code:
(see attached for what it looks like right now

)

import java.awt.BorderLayout;
//import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.*;

public class FirstGUI extends JFrame implements ActionListener
{
	public FirstGUI()
	{	
	
		
		setLayout(null);
		setSize(800, 400);
		setTitle("Wages");
		setLocationRelativeTo(null);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
	

		
		final JTextArea reportField = new JTextArea();
		reportField.setEditable(false);
		//scrollPane.setBounds(60,90,100,100);
		reportField.setBounds(60,90,100,100);
		reportField.setSize(560,200);	
		reportField.setLineWrap(true);
		JScrollPane scrollPane = new JScrollPane(reportField);
		scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);		

		
		
		
		add(reportField);
		add(scrollPane);
		
	
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

	public static void main(String args[])
  	{

      //Starts up GUI
		FirstGUI s = new FirstGUI();
      s.setVisible(true);
    
  	}
	
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>