winner126

Forward I'm heavy, backward I'm not. What am I?

winner126

Though im not really sure what the problem is, I think what you want is an action listener. Put an action listener on you "From the Grill" button, and then in your action listener code you will check to see if the event 'e' is equal to the button "From the Grill". If it is, then you will draw the other panel instead, something like Frame.setContentPane(GrillPanel).

You'll need to read a little bit about action listeners if you dont know though. Hope this helps, sorry if it doesnt but I didnt really understand the question

winner126 Unverified User

I'm trying to implement a chatroom using RMI and everything was fine until I tried to bring my GUI into the picture, from what I can see the RMI aspect is fine, the client is sending the info to the server, the server sends it to all clients with callback.

They seem to get the info because I can display the strings via joptionpanes, but I can't put the strings into the textarea! As it happens I can't seem to change anything in the GUI once the program has started (.setText("awdad") doesnt do anything). Heres my GUI

[CODE]
classpackage ChatroomApp;
import java.rmi.RemoteException;
import java.util.Scanner;

//import java.net.;
import java.awt.event.
;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.;
import java.awt.Color;
import java.io.
;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;

public class ChatGUI extends JFrame implements ActionListener{
String username;
String[] users = {"john","kathrine","eddie"};
//String sentMessage;

JPanel contentPane,chatPanel;
JButton sendMessage;
JTextArea chatLog;
JTextField messageField;

static Chatroom remote;
static ChatGUI gui;
//JList roomUsers;

ServerChanged sc;

boolean sendPressed = false;

public ChatGUI() throws RemoteException {
JFrame manager = this;
manager.setVisible(true);
   contentPane = new JPanel();
    contentPane = (JPanel)getContentPane();
    contentPane.setVisible(true);
    setBounds(150, 100, 750, 600);
     chatPanel = new JPanel();
      messageField = new JTextField();
            chatLog = new JTextArea();
            sendMessage = new JButton("Send");
            //roomUsers = new JList(users);

    contentPane.setBackground(Color.gray);

username = JOptionPane.showInputDialog("Enter username please");
    sc = new ClientImpl(username);

    chatPanel.setBackground(Color.lightGray);
    chatPanel.setBorder(BorderFactory.createLineBorder(Color.black,1));
    chatPanel.setLayout(null);

chatLog.setBackground(Color.white);
    chatLog.setEditable(true);
    chatLog.setLineWrap(true);
    chatLog.setText("chat log \n");
    chatLog.setBorder(BorderFactory.createLineBorder(Color.black,1));

    messageField.setBackground(Color.white);
    messageField.setEditable(true);
    messageField.addKeyListener(new MyKeyListener());
    messageField.addActionListener(this);
    messageField.setBorder(BorderFactory.createLineBorder(Color.black,1));

    sendMessage.addActionListener(this);

    //roomUsers.setBorder(BorderFactory.createLineBorder(Color.black,1));

    chatPanel.add(chatLog);
    chatPanel.add(messageField);
    chatPanel.add(sendMessage);
    //chatPanel.add(roomUsers);
    chatLog.setBounds(20,20,500,420);
    messageField.setBounds(20,460,500,60);
    sendMessage.setBounds(540,460,120,60);
    //roomUsers.setBounds(540,20,120,420);

    contentPane.add(chatPanel);

}

public static void main(String args[]) throws RemoteException{
    /*JFrame manager ...