aspose file tools*
The moose likes Beginning Java and the fly likes writing a GUI message board in Java 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 "writing a GUI message board in Java" Watch "writing a GUI message board in Java" New topic
Author

writing a GUI message board in Java

Chris Lavery
Ranch Hand

Joined: Nov 30, 2004
Posts: 54
hi everybody,
i have a java assignment in which i have to write the code for a java message board. Firstly im unsure if i would have to create a GUI that is a meassge board or just write a message board that is a GUI if that makes sense.
So far i have began by attempting to write a GUI but cannot seem to manage even the simplest. i have encluded some very basic code that i have started with. any help is much appreciated


import java.awt.*;
import java.awt.event.*;

public class MessageBoard {



public MessageBoard() {

}

super(" Message Board GUI");

buildGUI();
setSize(400,150);
setVisible(true);

}
}
[ October 28, 2005: Message edited by: Marilyn de Queiroz ]
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3170
    
  10
I assume the '}' after public MessageBoard() { is a typo. It shouldn't be there.

super(" Message Board GUI"); will not compile because the Object class (that MessageBoard implicitly extends) does not have a constructor that takes a String parameter.

I assume buildGUI() is where you build your GUI, so as that is what you are having problems with, can you post the code for it and say what errors you are getting.
[ October 28, 2005: Message edited by: Joanne Neal ]

Joanne
Chris Lavery
Ranch Hand

Joined: Nov 30, 2004
Posts: 54
so far that is everything i have, i have no code for the buildGUI at the moment. this is the first time i have dealt with GUI so im not sure what to do
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Originally posted by Chris Lavery:
so far that is everything i have, i have no code for the buildGUI at the moment. this is the first time i have dealt with GUI so im not sure what to do


I highly recommend the following: The Java� Tutorial - Trail: Creating a GUI with JFC/Swing
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I'll parrot a fantastic recommendation from the servlet forum. Write the guts of the thing - add a message, list new messages, retrieve a message, reply, etc. - entirely with classes you can run from the command line with individual class main() methods, some testing framework, JUnit tests or whatever. If those work, it will be much easier to hang a Swing or Web gui on the front.

I'm sure this advice is very hard to swallow the first time you hear it. If you want to take a chance with us and give it a try, we'll help you get it going.



A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Chris Lavery
Ranch Hand

Joined: Nov 30, 2004
Posts: 54
thanks stan,
id more than appreciate the help. im pretty confident, i think on how to write the code for the likes of the buttons and the text boxes etc. and also how to do the layout, my general real problem is just actually starting. before now i have only been writing simple java programs so this is a big step up i feel. i was wondering if you or anyone could answer a few questions about it:
1) im unsure as to whether i need a class and app file??
2)do i still need the fields and constructor and method layout (i know this may seem a silly question, only i have been taught to use that in every assignmnet but with examples i have seen for GUI's i dont see this order)
thanks everyone
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Your Swing windows and panels and such will be Java source just like any other class. I usually have a bunch of instance variables for the widgets I need to actually interact with and some builder methods that set up layout managers, add widgets, etc. I structure the code like the window:

Is that the kind of thing you were asking?

Oh, and I haven't read enough other folks Swing code to know if that is at all common or just my own habit. Somebody will jump in for sure if I'm being dumb about it.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Stan James:
... Write the guts of the thing - add a message, list new messages, retrieve a message, reply, etc. - entirely with classes you can run from the command line with individual class main() methods, some testing framework, JUnit tests or whatever. If those work, it will be much easier to hang a Swing or Web gui on the front...

Absolutely! In fact, I think this is a perfect answer to the original question of whether to "create a GUI that is a meassge board or just write a message board that is a GUI."

Chris: If you search for the "Model View Controller" pattern, you'll find a lot of information on this concept. Here's a nice example at an intro level...

http://csis.pace.edu/~bergin/mvc/mvcgui.html


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: writing a GUI message board in Java
 
Similar Threads
Game Tutorials -->> TicTacToe
urgent help required
writing a message board in java
Swing event handling for a JButton?
Forum on a WebSphere Portal Server