Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i cant figure out how to get code from console to go into my jtextarea (in my case its called console) if someone could help that would be amazeing


Java
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JButton;

public class StringPanel extends JPanel {
	
	private JTextArea console;
	private JTextField input;
	private JButton send;
	private JTextArea invintory;
	private JTextArea stats;
	
	public StringPanel() {
				
		console = new JTextArea();
		input = new JTextField();
		send = new JButton("Send");

		send.addActionListener(new ActionListener() {

			  public void actionPerformed(ActionEvent event) {
			    //code goes here
			  }

			});
		
		invintory = new JTextArea("Invintory");
		stats = new JTextArea();
		
		setupPanel();
	}
	
	private void setupPanel()
	{
		
		
		
		this.add(console);
		console.setBounds(10, 11, 311, 239);
		
		this.add(input);
		input.setBounds(10, 261, 311, 28);
		input.setColumns(10);
		
		this.add(send);
		send.setBounds(331, 261, 109, 26);
		
		this.add(invintory);
		invintory.setBounds(331, 89, 109, 161);
		
		this.add(stats);
		stats.setBounds(331, 11, 109, 67);
		setBackground(Color.GRAY);
		setLayout(null);
		
	}
}


What I have tried:

i have tried various other methods that people have posted on stack overflow but none seem to work with my code, wither that or i did not implement them right.
Posted
Comments
Richard MacCutchan 27-Jun-16 3:01am    
I don't see any code to accept input or to add text to any of the text fields.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900