This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes code for adding a message to message board Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "code for adding a message to message board" Watch "code for adding a message to message board" New topic
Author

code for adding a message to message board

Chris Lavery
Ranch Hand

Joined: Nov 30, 2004
Posts: 54
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

Joined: Oct 27, 2004
Posts: 198
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: code for adding a message to message board
 
Similar Threads
Need a GUI
Exiting a thread
Game Tutorials -->> TicTacToe
writing a GUI message board in Java
writing a message board in java