problemer med at skrive i jTextArea
Hejsa allesammenJeg er ved at lave en GUI for at teste om min klient server kode virker. og indtil videre ser den sådan ud (koden til gui)
package client;
import common.Spiller;
import java.util.*;
import javax.swing.*;
import java.awt.*;
//import com.borland.jbcl.layout.*;
import java.awt.event.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class ClientGUI extends JFrame {
ClientMain cliMain = new ClientMain();
ArrayList spillere;
JTextArea jTextAreaSpillere;// = new JTextArea();
JButton jButtonJoin = new JButton();
JTextField jTextFieldAlias = new JTextField();
JLabel jLabelAlias = new JLabel();
ControllerClient cc = new ControllerClient();
GridBagLayout gridBagLayout1 = new GridBagLayout();
public ClientGUI() {
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
this.getContentPane().setLayout(gridBagLayout1);
jButtonJoin.setText("Log på server");
jButtonJoin.addActionListener(new ClientGUI_jButtonJoin_actionAdapter(this));
jLabelAlias.setText("Alias");
jTextAreaSpillere = new JTextArea();
jTextFieldAlias.setText("");
jTextAreaSpillere.setEditable(false);
jTextAreaSpillere.setRows(100);
//jTextAreaSpillere.setText("");
this.getContentPane().add(jTextAreaSpillere, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(45, 37, 127, 0), 94, 230));
this.getContentPane().add(jLabelAlias, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(72, 58, 332, 0), 4, 0));
this.getContentPane().add(jTextFieldAlias, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(70, 0, 328, 0), 53, 0));
this.getContentPane().add(jButtonJoin, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(68, 9, 326, 26), 0, 0));
}
void jButtonJoin_actionPerformed(ActionEvent e) {
cc.join(jTextFieldAlias.getText());
}
public void setSpillere(ArrayList a)
{
spillere = a;
for(int x = 0; x<a.size();x++)
{
Spiller spiller = (Spiller) a.get(x);
String temp = spiller.getAlias();
System.out.print("spilleralias = " + temp + "\n");
jTextAreaSpillere.append(temp + "\n");
System.out.print(jTextAreaSpillere.getText());
this.jTextAreaSpillere.repaint();
}
}
}
class ClientGUI_jButtonJoin_actionAdapter implements java.awt.event.ActionListener {
ClientGUI adaptee;
ClientGUI_jButtonJoin_actionAdapter(ClientGUI adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButtonJoin_actionPerformed(e);
}
}
mit problem er den her
public void setSpillere(ArrayList a)
{
spillere = a;
for(int x = 0; x<a.size();x++)
{
Spiller spiller = (Spiller) a.get(x);
String temp = spiller.getAlias();
System.out.print("spilleralias = " + temp + "\n");
jTextAreaSpillere.append(temp + "\n");
System.out.print(jTextAreaSpillere.getText());
this.jTextAreaSpillere.repaint();
}
}
som i kan se, skal den tilføje noget til jTextAreaSpillere... og det gør den også på sin hvis, det kan jeg se når jeg beder den om at skrive den ud til consollen, men det vises ikke i GUI'en...
nogen forslag?
