Show textfield or textarea java [closed]

5

I can not display words in textfield (or textarea) in my code, several hours on it and still can not.

I have here a link to the code . The most important lines are these, but if you want to test the whole code, it's easier to help, I guess.

import javax.swing.JTextField;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

private JTextArea textArea;
int player;
private DataInputStream input;
private JTextField id;


JPanel middlePanel=new JPanel();     
JTextArea display=new JTextArea(12,12);
display.setEditable(true); //false
JScrollPane scroll=new JScrollPane(display);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
middlePanel.add(scroll);
window.add(middlePanel, BorderLayout.EAST);
display.setText("Jogador(Player) 1");


middlePanel.setBorder(new TitledBorder(new EtchedBorder(),"Informações                            Chat"));        
JTextArea display2=new JTextArea(12,12);
display2.setEditable(true); 
JScrollPane scroll2=new JScrollPane(display2);
scroll2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
middlePanel.add(scroll2);
window.add(middlePanel, BorderLayout.EAST);
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);    
window.resize(700,500);

I have doubts mainly in this part of code:

public void run()
{
    // Primeiro a jogar jogador 1, segundo 2
    try 
    {          
        player=input.readChar();
        textArea.setText("You are player \""+ player + "\"");
        myTurn=(player == '1' ? true : false);
    } 

Briefly: Quoted text "" is not shown for textArea or textField (only white squares with vertical scroll bars appear). So I'm really scratching, I have to deliver the work in a few days.

The only text that is shown is display.setText ("Player (1)");

Incidentally the JtextArea is all blank. I can not identify the problem.

    
asked by anonymous 10.06.2015 / 21:36

1 answer

0

Try to put in your code another quotation mark after the last sign of +, apparently it seems to miss one, maybe solve.

textArea.setText("You are player \""+ player + ""\"");
    
11.06.2015 / 19:43