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.