So I'm making a bulletin board project for my class and it gets all the data from a separate server. I need to make a GUI for it that can submit questions and draw the messages on a Jpanel. I have the panels separated into their own files like so,
private Client() {
//Set up Main Frame
JFrame frame = new JFrame("Chat Client");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1000, 1000);
ConnectPanel connectPanel = new ConnectPanel(st, this.grid);
PostPanel postPanel = new PostPanel();
GetPanel getPanel = new GetPanel();
PinPanel pinPanel = new PinPanel();
ClearPanel clearPanel = new ClearPanel();
Board boardPanel = new Board(this.grid);
JTabbedPane controls = new JTabbedPane(JTabbedPane.LEFT);
controls.add("Connect",connectPanel);
controls.add("Post",postPanel);
controls.add("Get",getPanel);
controls.add("Pin/Unpin",pinPanel);
controls.add("Clear/Shake",clearPanel);
//Adding Components to the frame.
frame.add(controls,BorderLayout.WEST);
frame.add(boardPanel,BorderLayout.EAST);
frame.setVisible(true);
}
I have a main Grid object in the Client Class(main class) to keep track of my messages, but I don't have a way to update the boardPanel when a button in connectPanel is clicked. I tried actionListeners but that doesn't seem to work or a thread that runs in an infinite loop. Any ideas on how I could make this work? Thanks!