Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code for adding a message to message board

 
Chris Lavery
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody,
so far i have created a GUI that shows a message board and beside it has textfields and areas for the user to enter their name, title of their message and the message itself. i also have functional quit buttons to exit the GUI and a clear button to reset all textfields and areas to having no text. my problem now is that i am trying to make an "add message" button so that once clicked the message will be displayed on the message board. as yet, i have had zero luck with this.
can anybody please suggest some code to help me out.
thanks in advance
 
Hentay Duke
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried something like this?


This of course is not an entire working example. Just some lines to give you an idea. And without seeing your code it's hard to say what you need. This may be to basic for your needs.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hentay's code is assuming the class that it is in implements the ActionListener interface. Also you would need to check the ActionEvent passed in to make sure the action that fired is from the "Add" Button.

You also want to seperate the ActionListener from the View, this is coupling the business logic to the view. But that is another discussion. The basics of what Hentay posted is what you want.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic